473,883 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

__SELF__?

I love the __FILE__ constant; it's been enormously useful. Is there a
constant that would be the equivalent of $PHP_SELF? That's also a useful
value, but according to the docs, "...may or may not [exist] in $_SERVER."
In a distributed app, may or may not doesn't fly. I'm surprised, if there
isn't a reliable way to retrieve this value.

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
May 10 '06 #1
37 6064
Alan Little wrote:
I love the __FILE__ constant; it's been enormously useful. Is there a
constant that would be the equivalent of $PHP_SELF? That's also a useful
value, but according to the docs, "...may or may not [exist] in $_SERVER."
In a distributed app, may or may not doesn't fly. I'm surprised, if there
isn't a reliable way to retrieve this value.


Alan,

If it's supplied by the web server, it's available. But PHP cannot guarantee
what the servers give PHP.

For instance, Apache and IIS both supply it. But Acme Instant Web Server might not.

__FILE__, OTOH, is under complete control of PHP, so PHP can guarantee its
existence.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
May 10 '06 #2
Alan Little wrote:
I love the __FILE__ constant; it's been enormously useful. Is there a
constant that would be the equivalent of $PHP_SELF? That's also a useful
value, but according to the docs, "...may or may not [exist] in $_SERVER."
In a distributed app, may or may not doesn't fly. I'm surprised, if there
isn't a reliable way to retrieve this value.

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/


PHP_SELF should always be present in a web environment. It's a PHP
variable (it's called PHP_SELF after all). The individual SAPI modules
are responsible for setting it, which they all do.

May 10 '06 #3
NC
Alan Little wrote:

I love the __FILE__ constant; it's been enormously useful.
Is there a constant that would be the equivalent of $PHP_SELF?
That's also a useful value, but according to the docs, "...may
or may not [exist] in $_SERVER."


This is a sweeoing generalization; under Apache and IIS,
$_SERVER['PHP_SELF'] is always available.

Cheers,
NC

May 10 '06 #4
NC
Alan Little wrote:

I love the __FILE__ constant; it's been enormously useful.
Is there a constant that would be the equivalent of $PHP_SELF?
That's also a useful value, but according to the docs, "...may
or may not [exist] in $_SERVER."


This is a sweeping generalization; under Apache and IIS,
$_SERVER['PHP_SELF'] is always available.

Cheers,
NC

May 10 '06 #5
On 2006-05-10, Alan Little <al**@n-o-s-p-a-m-phorm.com> wrote:
I love the __FILE__ constant; it's been enormously useful. Is there a
constant that would be the equivalent of $PHP_SELF? That's also a useful
value, but according to the docs, "...may or may not [exist] in $_SERVER."
In a distributed app, may or may not doesn't fly. I'm surprised, if there
isn't a reliable way to retrieve this value.


Why would you want the value? I still have to see my first good reason
to use it ;) (In case you want to redirect a user to the same place
where he came from after a form submit, using '#' as value for the
action is as good and it doesn't has the potential security issues as
$_SERVER['PHP_SELF'] has...)

--
Met vriendelijke groeten,
Tim Van Wassenhove <http://timvw.madoka.be >
May 10 '06 #6
Tim Van Wassenhove:
Why would you want the value? I still have to see my first good reason
to use it ;) (In case you want to redirect a user to the same place
where he came from after a form submit, using '#' as value for the
action is as good and it doesn't has the potential security issues as
$_SERVER['PHP_SELF'] has...)


I remember a similar discussion a while ago, and I went away thinking
there was something wrong with my PHP. I still don't know what
PHP_SELF is meant to be.

I see two relevant bug reports:

http://bugs.php.net/bug.php?id=13606 - says there was a documentation
problem, but the problem seems to persist

http://bugs.php.net/bug.php?id=18330 - I don't know what to make of
that dismissal

--
Jock

May 10 '06 #7
Carved in mystic runes upon the very living rock, the last words of
Jerry Stuckle of comp.lang.php make plain:
Alan Little wrote:
I love the __FILE__ constant; it's been enormously useful. Is there a
constant that would be the equivalent of $PHP_SELF? That's also a
useful value, but according to the docs, "...may or may not [exist]
in $_SERVER." In a distributed app, may or may not doesn't fly. I'm
surprised, if there isn't a reliable way to retrieve this value.

If it's supplied by the web server, it's available. But PHP cannot
guarantee what the servers give PHP.

__FILE__, OTOH, is under complete control of PHP, so PHP can guarantee
its existence.


I understand; that's what I like about __FILE__. I was wondering if there
were a similar constant with the same value as $PHP_SELF.

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
May 11 '06 #8
Carved in mystic runes upon the very living rock, the last words of
Chung Leong of comp.lang.php make plain:
Alan Little wrote:
I love the __FILE__ constant; it's been enormously useful. Is there a
constant that would be the equivalent of $PHP_SELF? That's also a
useful value, but according to the docs, "...may or may not [exist]
in $_SERVER." In a distributed app, may or may not doesn't fly. I'm
surprised, if there isn't a reliable way to retrieve this value.


PHP_SELF should always be present in a web environment.


I agree, but it isn't always. I've run into trouble relying on it in Phorm.

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
May 11 '06 #9
Carved in mystic runes upon the very living rock, the last words of NC of
comp.lang.php make plain:
Alan Little wrote:

I love the __FILE__ constant; it's been enormously useful.
Is there a constant that would be the equivalent of $PHP_SELF?
That's also a useful value, but according to the docs, "...may
or may not [exist] in $_SERVER."


This is a sweeping generalization; under Apache and IIS,
$_SERVER['PHP_SELF'] is always available.


I wish it were, but I've encountered instances where it wasn't.

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
May 11 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1939
by: Jacek Generowicz | last post by:
Where can I find information on the __self__ attribute of builtin functions ?
2
3241
by: Hallvard B Furuseth | last post by:
What's the difference between a built-in method and a method-wrapper object? Why has only the former a __self__, even though both are tied to the object on which to perform the operation? Why do list.pop and list.__len__ have different types at all? >>> .pop.__self__ >>> .__len__.__self__ Traceback (most recent call last): File "<stdin>", line 1, in ?
0
9933
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9781
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11121
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10734
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10836
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10407
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7960
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7114
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
3230
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.