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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -