Questions tagged [stdclass]

`stdClass` is php's generic empty class, kind of like Object in Java or object in Python.But not actually used as universal base class. Useful for anonymous objects, dynamic properties. It is used when casting other types to objects.

stdClass is php's generic empty class, kind of like Object in Java or object in Python.But not actually used as universal base class. Useful for anonymous objects, dynamic properties. It is used when casting other types to objects.

490 questions
7
votes
4 answers

PHP Array of a stdClass, How to get data?

I would like to print the value of [name]. I am just becoming familiar with standard defined classes and how they are called. Based on this example and logic $arrayobj = new…
sandraqu
  • 1,008
  • 1
  • 11
  • 29
6
votes
2 answers

SOAP Request with tags

This is my first time posting, so forgive me if I'm not very clear. I will also preface this by saying that I really know very little about php and web services. The issue I'm having is this: A SOAP request is generated by an outside source (a…
tehscott
  • 101
  • 8
6
votes
2 answers

PHP stdClass Object, how to get element with the 0 index

I have a stdClass Object like this: print_r($myobj); stdClass Object( [0] => testData ); So it is clear that I cannot get the value by $myobj->0. For getting this value I convert the object to an array, but are there any ways to get without…
sinitram
  • 503
  • 4
  • 14
6
votes
3 answers

How to instantiate stdClass in place

Is it it possible to do this in php? Javascript code: var a = {name: "john", age: 13}; //a.name = "john"; a.age = 13 Instantiate the stdClass variable on the fly ?
Florin
  • 63
  • 1
  • 3
5
votes
6 answers

PHP strict standards: is this bad?

When I create a standard class I mostly do: $test = null; $test->id = 1; $test->name = 'name'; However in strict-mode I get an error. So obviously the correct way of doing it is: $test = new stdClass(); $test->id = 1; $test->name = 'name'; So I am…
PeeHaa
  • 66,697
  • 53
  • 182
  • 254
5
votes
3 answers

Codeigniter - return my model object instead of stdClass Object

Not sure the best way of phrasing this so bear with me. Within Codeigniter I can return a record set of my object no problem but this is returned as a stdClass object not as an "model" object (for example a Page Object) which I can then use to make…
simnom
  • 2,430
  • 1
  • 22
  • 34
5
votes
3 answers

stdClass Object and array how to using php

I'm trying to get the twelve ids that this structure shows: stdClass Object ( [checkins] => stdClass Object ( [count] => 12 [items] => Array ( [0] => stdClass Object …
user638009
  • 223
  • 1
  • 9
  • 25
5
votes
2 answers

PHP loop through array of stdClass object

I have a query that I run in MySQL and it returns a result as an stdClass object as following : array(8){ [ 0 ]=>object(stdClass)#36(1){ [ "color" ]=>string(7)"#a0a0a0" }[ 1 ]=>object(stdClass)#35(1){ [ …
user3593154
  • 115
  • 2
  • 9
5
votes
1 answer

PHP: How to parse a stdClass Object?

I'm trying to parse this data that is returned from SmartyStreets (it's an address verification company). Here is an example: Array ( [0] => stdClass Object ( [input_index] => 0 [candidate_index] => 0 …
Edward
  • 8,322
  • 16
  • 45
  • 66
5
votes
6 answers

stdClass Object problems

I'm struggling to parse the below data using PHP. An API returns it, and I've tried various syntaxes. How do I return the data in a non-object way? Or, what's the syntax to call the data using the stdClass? Could I convert this to one data based…
ader
  • 53
  • 1
  • 1
  • 4
5
votes
5 answers

How to get class object with $query->row on Codeigniter

I'm currently working with the Codeigniter framemwork. In the code below, I would like to get an Animal_model object, not a stdClass Object.
Dacobah
  • 767
  • 3
  • 15
  • 33
5
votes
4 answers

How do you print an object, called * (asterisk)?

If print_r($object) returns stdClass Object ( [*] => sometext ) How do I get the property of the asterisk, i.e $object->*?
timofey.com
  • 3,763
  • 2
  • 24
  • 29
4
votes
3 answers

php appending string to stdClass object

I'm pulling records from database, and I have a filed called content_fr the _fr is being dynamicaly created based on a site language. Getting all records from the table gives me of course content_fr field. What I need to do is manually assign the…
Mike
  • 161
  • 5
  • 9
4
votes
1 answer

Expected argument of type "string", "stdClass" given Error

I'm using mailchimp-api-v3 for nodejs. I'm currently trying to update a user's tag but sometimes this error pops up and I have no idea what it means. I searched around but it doesn't seem like a lot of devs have encountered it. Any suggestions are…
4
votes
2 answers

How to fetch the values from stdClass in PHP?

I am working on my php to search for the values from the stdClass array. I have a hard time with fetching the values from the array because it will not fetch the values and store in the $body_attachment array when I tried to use ifdisposition and…
user11616198
1 2
3
32 33