|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-08-24 08:03 UTC] chinawolfs at hotmail dot com
Description:
------------
<?php
class php {
private $_url = null;
public function home($url) {
$this->_url = $url;
return $this->_url;
}
}
if(class_exists('php')) {
$php = new php();
}
print_r($php->home());
?>
when class_exists('php') eq true .the code have to process $php = new php();
but I see php manual "Returns TRUE if class_name is a defined class, FALSE
otherwise"
if the class_name is a defined or true,and I don't new a object.
Test script:
---------------
<?php
class php {
private $_url = null;
public function home($url) {
$this->_url = $url;
return $this->_url;
}
}
if(class_exists('php')) {
$php = new php();
}
print_r($php->home());
?>
Expected result:
----------------
$php is a new object and print_r home() method
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 08 12:00:01 2026 UTC |
sorry ,I forget the url argument. but I don't express oneself clearly idear with english. The class_exists method Return Value is "Returns TRUE if class_name is a defined class, FALSE otherwise.". if(class_exists('php')) { $php = new php(); } if class_exists('php') is true ,and then $php = new php() could process. but 'php' is not defined class.> if class_exists('php') is true ,and then $php = new php() could process. but 'php' is not defined class. Yes, it is. You just defined it above: "class php {". I'm closing this as bogus.