Doc #52684 [Fbk->Opn]: document problem with class_exists function
| From: | chinawolfs at hotmail dot com | Date: | Tue, 24 Aug 2010 07:58:01 +0000 |
| Subject: | Doc #52684 [Fbk->Opn]: document problem with class_exists function | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-4917@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52684&edit=1
ID: 52684
User updated by: chinawolfs at hotmail dot com
Reported by: chinawolfs at hotmail dot com
Summary: document problem with class_exists function
-Status: Feedback
+Status: Open
Type: Documentation Problem
Package: Documentation problem
Operating System: window xp
PHP Version: 5.2.14
Block user comment: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2010-08-24 09:49:31] salathe@php.net
Your sample code will raise a warning on line 4 (Missing argument 1 for
php::home()) and a notice on line 5 (Undefined variable: url); it will
create a
new instance of the php class. If a value is passed along to the method
call,
your script works fine.
Could you elaborate on the nature of the documentation bug, please? I
don't see
it.
------------------------------------------------------------------------
[2010-08-24 08:03:09] 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
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52684&edit=1