PHP: fatal error while using namespaces -
i have file learn.php
<?php ini_set("display_errors", "1"); include ("learn2.php"); ?>
learn2.php contains
<?php namespace test { function f1() { echo "test"; } const x = "1<br>"; } ?>
maybe i'm blind, why learn.php give me following fatal error?
fatal error: namespace declaration statement has first statement in script in /var/www/html/learn2.php on line 2
the syntax should just
namespace test;
no curly brackets.
after namespace declaration, should declare class hold function , const property. @ least const doesn't make sense itself.
Comments
Post a Comment