Home  >  Article  >  Backend Development  >  A brief analysis of the specific meaning of PHP object_PHP tutorial

A brief analysis of the specific meaning of PHP object_PHP tutorial

WBOY
WBOYOriginal
2016-07-15 13:30:48969browse

Everyone knowsPHP object initialization: To initialize an object, use the new statement to instantiate the object into a variable.

  1. < ?php
  2. class foo
  3. {
  4. function do_foo()
  5. {
  6. echo "Doing foo.";
  7. $bar
  8. = new
  9. foo;
  10. $bar->do_foo(); ?>
  11. Convert to PHP object: If you convert an object to an object, it will not change anything. If a value of any other type is converted to an object, an instance of the built-in class stdClass will be created. If the value is NULL, the new instance is empty. For any other value, the member variable named scalar will contain the value.
  12. http://www.bkjia.com/PHPjc/446255.html

www.bkjia.com

true

<ol class="dp-xml">
<li class="alt"><span><span class="tag"><</span><span> ?php  </span></span></li><li><span>$</span><span class="attribute">obj</span><span> = (object) 'ciao';  </span></li><li class="alt"><span>echo $obj-</span><span class="tag">></span><span>scalar; // outputs 'ciao'  </span></span></li>
<li>
<span class="tag">?></span><span>   </span>
</li>
</ol>
http: //www.bkjia.com/PHPjc/446255.html

TechArticle
Everyone knows that PHP object initialization: To initialize an object, use the new statement to instantiate the object into a variable. ?php classfoo { functiondo_foo() { echoDoingfoo.; } } $ bar...

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn