Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 594
  • Last Modified:

Fatal error: Class 'Judy' not found in C:\wamp\www\variables-references\9-object-instantiation.php on line 4

<?php
$x = new stdClass;
$y = new stdClass;
$z = new Judy;

var_dump($x, $y); // object(stdClass)#1 (0) { } object(stdClass)#2 (0) { }

Open in new window


I added $z=new Judy;
Fatal error: Class 'Judy' not found in C:\wamp\www\variables-references\9-object-instantiation.php on line 4

how can $x and $y be called without a class
0
rgb192
Asked:
rgb192
3 Solutions
 
Juan OcasioCommented:
It's tough to say what's going on with such a limited amount of info (for me at least).  I' not sure where the classes are created, or whether or not you have included them in the file that holds the above mentioned code.
0
 
mankowitzCommented:
stdClass is a php generic class, like Object in other languages. It is already a defined type. Judy is not defined.
0
 
Ray PaseurCommented:
A search of the PHP.net web site for stdclass finds this page:
http://www.php.net/manual/en/reserved.classes.php
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
rgb192Author Commented:
stdClass is a php generic class, like Object in other languages. It is already a defined type. Judy is not defined.
generic class, but where is the class?


from http://www.php.net/manual/en/reserved.classes.php
Standard Defined Classes ΒΆ

These classes are defined in the standard set of functions included in the PHP build.

Directory
Created by dir().
stdClass
Created by typecasting to object.
__PHP_Incomplete_Class
Possibly created by unserialize().

There are not many words in the php manual
I still do not understand.
0
 
Ray PaseurCommented:
Here is something that does the same things as StdClass.  It's just an empty class definition - no properties or methods.  You can add your own properties.

<?php // demo/temp_stdclass.php
ini_set('display_errors', TRUE);
error_reporting(E_ALL);

Class StandardClass
{
}

Open in new window

0
 
rgb192Author Commented:
<?php // demo/temp_stdclass.php
ini_set('display_errors', TRUE);
error_reporting(E_ALL);

Class StandardClass
{
}

$x=new StandardClass();
$y=new StandardClass();
var_dump($x,$y);

Open in new window



object(StandardClass)#1 (0) { } object(StandardClass)#2 (0) { }

I also do not understand that the notation can be
$x=new StandardClass();
$y=new StandardClass();

or
$x=new StandardClass;
$y=new StandardClass;
0
 
Ray PaseurCommented:
It's just the way PHP code works, that's all.  If you put the parenthetical expression after the statement you get it to run the class constructor (if any).  This would make sense if there were arguments needed in the constructor.
0
 
rgb192Author Commented:
A generic class and sometimes classes have constructors.

Thanks.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now