473,473 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

autoload does not call class

59 New Member
Expand|Select|Wrap|Line Numbers
  1.  
  2. function __autoload($class){
  3.  
  4.   include(trim(str_replace('_','/',$class)).'.php';
  5.   if(class_exist){ echo 'my class exists\n'; }
  6.  throw new Exception('class cannot be loaded');
  7. }
  8.  
  9. try{
  10.   new dir_to_myclass();
  11. }catch(exception $e){
  12.   echo $e->getmessage();
  13. }
  14.  
dir/to/myclass.php
Expand|Select|Wrap|Line Numbers
  1.  
  2. echo "here<br/>";
  3.  
  4. class mycalss {
  5.  
  6.   public function __contruct { echo 'myclass instatiated'; }}
  7.  
outputs:
myclass exists
here
class cannot be loaded

why is autoload not instatiating myclass?
Oct 9 '11 #1
2 1715
YarrOfDoom
1,247 Recognized Expert Top Contributor
Because you misspelled "myclass" in dir/to/myclass.php?
I've also got a feeling it's going to try to create a dir_to_myclass-object rather than a myclass-object.
Oct 10 '11 #2
freefony
59 New Member
thanks YarrofDoom i got it working i removed the try,catch block and it works just fine i dont know why a try block should stop autoloader from calling the class
Oct 13 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Ken Varn | last post by:
Everytime I call Process.GetCurrentProcess() the system goes out to the floppy drive. Why does this happen. I decided to use FileMon to get a log of what is happening when this occurs. Here is...
3
by: zx.zhangxiong | last post by:
Dear all, I'm puzzled about the usage of class member function. Any help would be appreciated. class Account { ...
6
by: Davinci_Jeremie | last post by:
Hi Newbee here to C# I have a simple questions... In a Hello world example how does the class object Hello exist with out creating it? I come from object pascal where everything object is...
4
by: Bonato Pierantonio | last post by:
Hi All, It is possible inside a SCRIPT tag in the HTML page to call a SUB or FUNCTION write in the codebehind ? Example in the HTML <SCRIPT Language=vbscript> sub mySub call mySecondSub end...
10
by: Goran Djuranovic | last post by:
Hi all, Does anyone know how to declare a variable in a class to be accessible ONLY from a classes instantiated within that class? For example: ************* CODE ***************** Public...
11
by: Raja Chandrasekaran | last post by:
Hai folks, I have a question to get exact answer from you people. My question is How Static class is differ from instance class and If you use static class in ASP.NET, ll it affect speed or...
3
by: ChrisEdgemon | last post by:
I'd like to implement a subclass of string that works like this: True False True My best attempt for something like this is: class MyString(str): def __init__(self, seq):
34
by: Creativ | last post by:
Why does Thread class not support IDisposable? It's creating quite some problem. Namely, it can exhaust the resource and you have not control over it.
5
by: robbiesmith79 | last post by:
Hey fellow nerds, Take this code for example: class hello { function world() { echo "Hello"; } }
7
by: Peter Morris | last post by:
interface Interface1 { } interface Interface2 : Interface1 { } class A : Interface2 {
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.