if and else execute together! (class extends)
Posted: Tue Mar 09, 2010 6:18 am
i create a simple php script :
in browser i get
im astonished!
Code: Select all
<?php
class newclass {
public function newfunc() {
echo 'class exist';
}
}
if (true) {
class myclass1 extends newclass {}
}
else {
class myclass2 extends newclass {}
}
$test = new myclass2;
$test->newfunc();
, but in cli i getclass exist
--------------------run with php vs php-cgi--------------------Fatal error: Class 'myclass2' not found in test.php on line 15
[root@server]# php test.php
Fatal error: Class 'myclass2' not found in test.php on line 15
[root@server]# php-cgi test.php
X-Powered-By: PHP/5.2.6
Content-type: text/html
class exist
im astonished!