the define function with namespace
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
Related Article: track visits by date
is a PHP discussion thread by master-tech that has 5 replies and was last updated 7 months ago.
ZER09
Junior Poster in Training
74 posts since Jul 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0
You can access globals with the backslash inside namespaces:
echo \protect;
diafol
Keep Smiling
10,842 posts since Oct 2006
Reputation Points: 1,675
Solved Threads: 1,536
Skill Endorsements: 61
ZER09
Junior Poster in Training
74 posts since Jul 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0
Question Answered as of 7 Months Ago by
diafol