Jump to content

to define or not to define that's my question :)


fortnox007

Recommended Posts

Hi all,

 

I was reading a bit in the manual about the defined function. Since i have seen it being used quite a lot to disallow direct access. But one of the comments made me think if there are any alternatives to get the same.

it's this comment: http://www.php.net/manual/en/function.defined.php#89886

 

If i read it correct it tells that defined() seems to be pretty slow. I was thinking, if that is the case what are the alternatives... :shrug:

 

Does anyone know how to interpret this comment and if there are alternatives? I am not yet a guru tofully understand the results.

 

cheers! :)

Thanks Thorpe for your reply!

 

So may i assume, if i have something like this:

an index.php that includes other phpfiles the following is the way to restrict direct access to php files in the webfolder

<?php
define('my_constant', 1);
include('anyfolder/anyfile.php');
?>

and in the included file

<?php
   defined('my_constant')or die('bla bla bla');
?>

 

Thanks for your reply mjdamato! :)

this one is solved ::)

 

-edit: this was something i saw in quite some cms frameworks, which also aim at crappy shared host users, so i thought i was a good thing to know about this hehe :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.