Everyone knowsPHP object initialization: To initialize an object, use the new statement to instantiate the object into a variable.
- < ?php
- class foo
- {
- function do_foo()
- {
- echo "Doing foo.";
- $bar
- = new
- foo;
- $bar->do_foo(); ?>
-
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.
-
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>
Copy after login
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...