473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

is stdClass officially supported by PHP ?

Hello,

It can be very usefull to code:
$obj = new stdClass;
Unfortunately the few that the documentation officially tells about
this class is:
******************************
The name stdClass is used internally by Zend and is reserved. You
cannot have a class named stdClass in PHP.
http://www.php.net/manual/en/language.oop.php
******************************

It seems that some Pear packages instanciate this class.
But should we do the same for code intended for public releases?

--------------------------------------
Skrol29
http://www.tinybutstrong.com
--------------------------------------

Jun 6 '06 #1
4 13475
Skrol29 wrote:
Unfortunately the few that the documentation officially tells about
this class is:
******************************
The name stdClass is used internally by Zend and is reserved. You
cannot have a class named stdClass in PHP.
http://www.php.net/manual/en/language.oop.php
******************************

It seems that some Pear packages instanciate this class.
But should we do the same for code intended for public releases?


This just means you cannot do:

class stdClass {}

But can savely do:

$foo = new stdClass;

Another example:

$obj = (object) null;
print is_a($obj, 'stdClass') ? 1 : 0;

Or:

$obj = (object) null;
print $obj instanceof stdClass ? 1 : 0;

Both print 1...
JW
Jun 6 '06 #2
Thanks Janwillem,

It seems that :
$obj = (object) null;
is documented, but the equivalent :
$obj = new clsClass;
is not documented, except in the examples provided under the doc.
clsClass is just mentioned to be a special class name but usage is not
described. Which maybe means it can change in the future.

------------------------------------------
Skrol29
http://www.tinybutstrong.com
------------------------------------------

Janwillem Borleffs a écrit :
Skrol29 wrote:
Unfortunately the few that the documentation officially tells about
this class is:
******************************
The name stdClass is used internally by Zend and is reserved. You
cannot have a class named stdClass in PHP.
http://www.php.net/manual/en/language.oop.php
******************************

It seems that some Pear packages instanciate this class.
But should we do the same for code intended for public releases?


This just means you cannot do:

class stdClass {}

But can savely do:

$foo = new stdClass;

Another example:

$obj = (object) null;
print is_a($obj, 'stdClass') ? 1 : 0;

Or:

$obj = (object) null;
print $obj instanceof stdClass ? 1 : 0;

Both print 1...


JW


Jun 6 '06 #3

Skrol29 wrote:
Hello,

It can be very usefull to code:
$obj = new stdClass;
Unfortunately the few that the documentation officially tells about
this class is:
******************************
The name stdClass is used internally by Zend and is reserved. You
cannot have a class named stdClass in PHP.
http://www.php.net/manual/en/language.oop.php
******************************

It seems that some Pear packages instanciate this class.
But should we do the same for code intended for public releases?

--------------------------------------
Skrol29
http://www.tinybutstrong.com
--------------------------------------


Not that I'm aware of. I vaguely remember that it was called something
else in PHP 3, something like phpStdClass.

It's probably better to let the object autovivicate.

Jun 6 '06 #4
Skrol29 wrote:
Hello,

It can be very usefull to code:
$obj = new stdClass;
Unfortunately the few that the documentation officially tells about
this class is:

<snip>

IIRC, it's a base PHP class. It is usually used to stuff properties:
$config = new stdClass;
$config->name = 'Foo site';
$config->db = 'foo';

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jun 6 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: red | last post by:
If I use PEAR to produce an accociative array from a mysql table, and display the array with print_r, it says it is an array and it displays values like a regular array: Array ( => 1 =>...
5
by: eadams | last post by:
I've been tasked with writing an application in VB.Net that will manipulate messages in a user's Inbox. My Exchange admin prefers that I use MAPI; I don't really care, but I want this to be as...
2
by: juglesh | last post by:
hello, i have a d/l'd class that gives an array which prints like this: stdClass Object ( ] => stdClass Object ( => text => => fisrt name => yes
4
by: David | last post by:
Hello When I try to open a connection to a sql server database from my aspnet app I get the following exception message: 'ResourcePool' is not supported on the current platform. I can connect OK...
5
by: JamesG | last post by:
Hi, I have the following object, I need to extract the SysMessage property. stdClass Object ( =stdClass Object ( =Your consignment could not be found on our system ) ) I could do this:
2
by: Jean Marie | last post by:
Hi, i have a problem with the usage of stdClass. From a SOAP based web service i get a code list as an array of stdClass instances: array ( 0 => stdClass::__set_state(array(
9
ebcovert3
by: ebcovert3 | last post by:
Ok, I really need help. I am running EE (an older version admittedly) but this just started happening. I noticed a lot of spam accounts being requesting authorization to my website. I went in to the...
1
by: electronik | last post by:
Hello! My var_export() from $object says: stdClass::__set_state(array( 'event_id' => '21', 'test' => 5, 'anode' => NULL, )) I want to access 'anode'.
6
by: muckymuck | last post by:
Hello, i would like to know how i can get better output from a foreach. this code: $x = $wpdb->get_results("SELECT * FROM " . WP_PLAATJES); foreach ($x as $y) { print_r($y); var_dump( $y...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.