473,327 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

PHP_SELF (quick question..)

Hi there,

I know the code $PHP_SELF to find out
the name of a file itself. Only if you
include a file with $PHP_SELF in it, it takes
the name of the parent-file.

How do i get the name of the actual file...

Hope this is clear enough.

Greetings
Jul 17 '05 #1
5 1685
knoak wrote:
Hi there,

I know the code $PHP_SELF to find out
the name of a file itself. Only if you
include a file with $PHP_SELF in it, it takes
the name of the parent-file.

How do i get the name of the actual file...


echo __FILE__;

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
Jul 17 '05 #2
Justin Koivisto wrote:
knoak wrote:
Hi there,

I know the code $PHP_SELF to find out
the name of a file itself. Only if you
include a file with $PHP_SELF in it, it takes
the name of the parent-file.

How do i get the name of the actual file...

echo __FILE__;


of course, you could also check:

print_r($_SERVER);

for any relavent entries.

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
Jul 17 '05 #3
Justin Koivisto wrote:
knoak wrote:
Hi there,

I know the code $PHP_SELF to find out
the name of a file itself. Only if you
include a file with $PHP_SELF in it, it takes
the name of the parent-file.

How do i get the name of the actual file...


echo __FILE__;


And if you just want the filename without the directory path etc
echo basename(__FILE__);

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Jul 17 '05 #4
Thanks a lot,

This is excactly what i meant.

Greetings
Jul 17 '05 #5
It's me again:

If i get this right, this would be a waterproof way to protect
pages that are meant to be included from being viewed 'unauthorized':

$page=basename($PHP_SELF);
$file=basename(__FILE__);
if ($page==$file){header('Location: http://domain.com/');}

Is that correct?

Thanks again and greetings..
Jul 17 '05 #6

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

Similar topics

1
by: jack | last post by:
I pulled this script out of a larger one to test, and I can't figure it out. If I keep this script in the same directory as the files I want to read, it works fine, but if I move the script out of...
10
by: Snake | last post by:
Hello guys, I have a quick question about pointers. When I say int *p; *p = 40; cout << *p; why does that produce and error message(something about fault address)? Isnt that I created a...
30
by: Christopher Benson-Manica | last post by:
Given the following: char s="Hello, world\n!"; Are all the following guaranteed to produce the same output? printf( "%s", s ); fprintf( stdout, "%s", s ); fwrite( s, sizeof(char),...
5
by: tariq | last post by:
Hi, got a quick question on al.exe i have an assembly say library.dll without any strong name i have a sn pair say org.snk how do i sign library.dll with org.snk using al? tx -T
1
by: Mike | last post by:
Hi, I am using an enum to map to certain columns instead of using the string name. When I use the enum as the indexer in a datarow it forces me to cast it into an int. Shouldn't this be...
6
by: z_learning_tester | last post by:
Quick question- What happens if you have a private class with a public static method? Can you still say the following? Lets say you are making this call from another class, say class2... int...
3
by: craig | last post by:
Quick question for the experts... Whenever I set the Image property of a PictureBox on one of my forms to a PNG graphic file on my hard drive, I get the following runtime error when I try to run...
2
by: Rudy | last post by:
Hello all! Have a quick question on drop down list. Need to make a year ddl, 1900 to 1987. Is there a quick way to do this. I'm not binding this, just loading it in the items collection. ...
3
by: Brian | last post by:
A quick question here - What can be achieved in IL which is not possible in C# ? o Creation of an ArrayList o Creation of a Dictionary o Creation of a two dimensional array...
1
by: JustTrev | last post by:
Hi I have a quick question. I'm studying how XML works in sq server 2005, and I've hit the following code online that I can't completely understand (see below code). I know what it does, how it...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.