I have a simple php library that i am using, now i wnat to upgrade it. I want to create namespace on it so my class will be inside on the namespaces bu t i got an error when i i tried to use namespace.
here a sample
<?php
defined('protect')||(header("HTTP/1.0 404 Not Found"));
require_once 'conf/configuration.php';
class string{
function __construct(){
//some code;
}
//some function;
}
?>
I used the defined function to protect the php file for direct accesss.
Now when i used namespace the code look like this.
<?php
defined('protect')||(header("HTTP/1.0 404 Not Found"));
namespace teststring;
{
require_once 'conf/configuration.php';
class string{
function __construct(){
//some code;
}
//some function;
}
}
?>
now it will get an error surely because the namespace should be on the very first line. but when i put the defined function inside the namespace i think it cant protect the file from direct access, i already googled this but so far i got no good results.
i am asking how to protect my php files from direct access when i am using namespace?
I will appreciate for any help will come. thanks
btw sorry for my bad english