473,382 Members | 1,386 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,382 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 13474
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.