CakeFest 2025 Madrid: The Official CakePHP Conference

Voting

: three minus one?
(Example: nine)

The Note You're Voting On

erguven dot m at gmail dot com
8 years ago
if you want to use a class which exists in a name space, use it full name. simple_load_string did not recognize short one.

class.new.php
<?php
namespace foo\bar;

class new extends
SimpleXMLElement
{
public function do()
{
echo
"done";
}
}
?>

false.php
<?php
use \foo\bar\new;

$result = simplexml_load_string($xml, 'new'); // it gives warning
$result->do(); // fatal error
?>

true.php
<?php
use \foo\bar\new;
$result = simplexml_load_string($xml, '\foo\bar\new');

$result->do(); // prints done
?>

<< Back to user notes page

To Top