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! :)

Link to comment
Share on other sites

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');
?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.