A
A
Artem2015-08-03 09:35:52
PHP
Artem, 2015-08-03 09:35:52

How to access a property of a PHP object?

Please tell me, some unexpected problem arose:

$db = new DB\Mongo('mongodb://localhost:27017', 'test');
$sessions = new DB\Mongo\Mapper($db,'sessions');
$sessionsList = $sessions->find(array("sid"=>$sid));
var_dump($sessionsList[0]->expired);

Output:
object(MongoDate)#17 (2) {
  ["sec"]=>
  int(1438577420)
  ["usec"]=>
  int(0)
}

And if so:
$sec = $sessionsList[0]->expired;
var_dump($sec);

It won't output anything!
How can I set $sessionsList[0]->expired->sec to a variable?
The logs are empty, no errors..

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2015-08-03
@melkij

var_dump physically (ext/standard/var.c, php_var_dump function) cannot work and output nothing.
If you really don't have any stdout, then you're crashing somewhere else. Run in CLI, there are fewer logs to watch. Check the return code of the script.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question