php-internals

What is #<some-number> next to object(someClass) in var_dump of an object? I have an inference. Am I right?

人走茶凉 提交于 2019-11-26 07:46:05
问题 This is the code & its output I used to draw the inference below: class a { public $var1; public $var2; } $obj0 = new a; var_dump($obj0); class b { public $var1; public $var2; public $var3; } $obj1 = new b; var_dump($obj1); $obj2 = new stdClass; var_dump($obj2); $obj3 = new stdClass; var_dump($obj3); $obj4 = new stdClass; var_dump($obj4); $obj5 = new stdClass; var_dump($obj5); var_dump(new stdClass); $obj6 = new stdClass; var_dump($obj6); The output: object(a)#1 (2) { [\"var1\"]=> NULL [\

What does “zend_mm_heap corrupted” mean

谁说胖子不能爱 提交于 2019-11-26 05:16:54
问题 All of the sudden I\'ve been having problems with my application that I\'ve never had before. I decided to check the Apache\'s error log, and I found an error message saying \"zend_mm_heap corrupted\". What does this mean. OS: Fedora Core 8 Apache: 2.2.9 PHP: 5.2.6 回答1: After much trial and error, I found that if I increase the output_buffering value in the php.ini file, this error goes away 回答2: I was getting this same error under PHP 5.5 and increasing the output buffering didn't help. I

Why don&#39;t PHP attributes allow functions?

[亡魂溺海] 提交于 2019-11-26 04:49:02
问题 I\'m pretty new to PHP, but I\'ve been programming in similar languages for years. I was flummoxed by the following: class Foo { public $path = array( realpath(\".\") ); } It produced a syntax error: Parse error: syntax error, unexpected \'(\', expecting \')\' in test.php on line 5 which is the realpath call. But this works fine: $path = array( realpath(\".\") ); After banging my head against this for a while, I was told you can\'t call functions in an attribute default; you have to do it in

print_r() adds properties to DateTime objects [duplicate]

99封情书 提交于 2019-11-26 04:28:31
问题 This question already has an answer here: Why can't I access DateTime->date in PHP's DateTime class? Is it a bug? 5 answers Consider the following code sample: $m_oDate = new DateTime(\'2013-06-12 15:54:25\'); print_r($m_oDate); echo $m_oDate->date; Since PHP 5.3, this produces (something like) the following output: DateTime Object ( [date] => 2013-06-12 15:54:25 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) 2013-06-12 15:54:25 However the following code: $m_oDate = new DateTime(\

Parentheses altering semantics of function call result

只愿长相守 提交于 2019-11-26 03:55:43
问题 It was noted in another question that wrapping the result of a PHP function call in parentheses can somehow convert the result into a fully-fledged expression, such that the following works: <?php error_reporting(E_ALL | E_STRICT); function get_array() { return array(); } function foo() { // return reset(get_array()); // ^ error: \"Only variables should be passed by reference\" return reset((get_array())); // ^ OK } foo(); I\'m trying to find anything in the documentation to explicitly and

How does PHP &#39;foreach&#39; actually work?

微笑、不失礼 提交于 2019-11-25 23:56:52
问题 Let me prefix this by saying that I know what foreach is, does and how to use it. This question concerns how it works under the bonnet, and I don\'t want any answers along the lines of \"this is how you loop an array with foreach \". For a long time I assumed that foreach worked with the array itself. Then I found many references to the fact that it works with a copy of the array, and I have since assumed this to be the end of the story. But I recently got into a discussion on the matter, and