Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-03-30
8
Medium Priority
?
574 Views
Last Modified: 2014-03-31
<?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
Comment
Question by:rgb192
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 15

Expert Comment

by:Juan Ocasio
ID: 39964930
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
 
LVL 24

Accepted Solution

by:
mankowitz earned 668 total points
ID: 39964935
stdClass is a php generic class, like Object in other languages. It is already a defined type. Judy is not defined.
0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1332 total points
ID: 39965054
A search of the PHP.net web site for stdclass finds this page:
http://www.php.net/manual/en/reserved.classes.php
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:rgb192
ID: 39965091
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
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39965112
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
 

Author Comment

by:rgb192
ID: 39965419
<?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
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1332 total points
ID: 39965430
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
 

Author Closing Comment

by:rgb192
ID: 39966758
A generic class and sometimes classes have constructors.

Thanks.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question