You are here: Re: __SELF__? « PHP Programming Language « IT news, forums, messages
Re: __SELF__?

Posted by Chung Leong on 10/12/28 11:47

Alan Little wrote:
> A couple of examples:
>
> 1. Phorm plugins use it to ensure they're being called from Phorm.
> I encourage users to secure their plugins directory with .htaccess
> or equivalent for their server, but users don't always do as they're
> encouraged. The idea is to prevent
>
> http://www.example.com/phorm/plugins/someplugin.php

<?php include("my_usual_rant_about_using_includes_as_functions.php");
?>

I don't really get why it's necessary to use PHP_SELF for this suppose.
Surely it's easier to do a define('IN_PHORM', 1) and then check for
the presence of the constant. Even easier is to have all these plug-ins
of yours call a function within Phorm. If the script is accessed
directly, it automatically blows up.

> 2. I have a homebrew template processor I use in all my applications.
> The calling script can, of course, specify the template, but if it
> doesn't, the default is (for example) example.html if called from
> example.php. Using $PHP_SELF works fine for me, but I've been thinking
> of making it generally available.

Still, you don't really need to know the actually URI. All you need is
the filename, which you can obtain reliably through debug_backtrace().

Having an application "know where it is" tend to cause problems during
deployment. Recently I've had to proxy a few sites through Apache
mod_proxy and the presence of absolute URLs was a major headache.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация