473,395 Members | 1,379 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,395 software developers and data experts.

Pre-Defined Variable For Calling PHP File.

66
[PHP]//page1.php
<?php
include('pagebase.php');
?>

//pagebase.php
<?php
echo __CALLING_FILE__; // outputs the previous php file. 'page1.php'
?>[/PHP]

I dont know the equivalent of __CALLING_FILE__. Please let me know on how to determine the previous file or the calling file.
Jul 31 '07 #1
8 1797
kovik
1,044 Expert 1GB
What language is __CALLING_FILE__ from...? And what is it that you are trying to do?
Jul 31 '07 #2
eros
66
What language is __CALLING_FILE__ from...? And what is it that you are trying to do?
__CALLING_FILE__ is not a PHP code.. I put that for example... I am searching for similar functionality... a Pre-Defined of PHP that gives the parent or the calling php file...in order to determine who was called the pagebase.php.. and use it into conditional statement for different processes..

[PHP]<?php
//pagebase.php
switch ( __CALLING_FILE__ ) {
case "index.php":
//codes here if index.php is the calling php file.
break;
case "page1.php":
//codes here if page1.php is the calling php file.
break;
case.............
//codes here if ????.php is the calling php file.
break;..........
}
?>[/PHP]
Aug 1 '07 #3
kovik
1,044 Expert 1GB
Yeah, that's not possible, but it's halfway senseless, anyway.

You do know that you can attach a query string when including a file, right? Maybe you could add this to your includes:

[php]include 'foo.php?callingFile=' . basename(__FILE__);[/php]

Then check $_GET['callingFile'] in the included file.
Aug 1 '07 #4
eros
66
Yeah, that's not possible, but it's halfway senseless, anyway.

You do know that you can attach a query string when including a file, right? Maybe you could add this to your includes:

[php]include 'foo.php?callingFile=' . basename(__FILE__);[/php]

Then check $_GET['callingFile'] in the included file.
Yes that's it, but unfortunately i got an error Failed opening required
[PHP]require_once '../phpbase.php?callingFile=' . basename(__FILE__);[/PHP]
Aug 1 '07 #5
eros
66
[PHP]<?php
include '../phpbase.php?var=1';
//.................
?>[/PHP]

Error Message: failed to open stream: Invalid argument
Aug 2 '07 #6
kovik
1,044 Expert 1GB
Then you'll need to create a more sensible program flow. What is it that you are trying to do....?

You could try using defined constants.

[php]// page1.php
define('PAGE1', true);[/php]

[php]// page2.php
if(defined('PAGE1'))
{
...
}[/php]
Aug 2 '07 #7
eros
66
Then you'll need to create a more sensible program flow. What is it that you are trying to do....?

You could try using defined constants.

[php]// page1.php
define('PAGE1', true);[/php]

[php]// page2.php
if(defined('PAGE1'))
{
...
}[/php]
In page1.php was done well but in page2.php, when passed through to if(defined('PAGE1')), "Constant PAGE1 already defined" was noticed. Returns false value.
Aug 6 '07 #8
kovik
1,044 Expert 1GB
In page1.php was done well but in page2.php, when passed through to if(defined('PAGE1')), "Constant PAGE1 already defined" was noticed. Returns false value.
Sounds like you made a typo.
Aug 6 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: Headless | last post by:
I've marked up song lyrics with the <pre> tag because it seems the most appropriate type of markup for the type of data. This results in inefficient use of horizontal space due to UA's default...
3
Pre
by: Neal | last post by:
A few questions about pre... When presenting preformatted text using the white-space: pre; property/value, Opera renders long lines at small viewport widths as exiting the borders of the...
7
by: Alan Illeman | last post by:
How do I set several different properties for PRE in a CSS stylesheet, rather than resorting to this: <BODY> <PRE STYLE="font-family:monospace; font-size:0.95em; width:40%; border:red 2px...
2
by: Buck Turgidson | last post by:
I want to have a css with 2 PRE styles, one bold with large font, and another non-bold and smaller font. I am new to CSS (and not exactly an expert in HTML, for that matter). Is there a way to...
5
by: Porthos | last post by:
I'm authoring an XML document and using the <pre> html tag for the portions that are not dynamically generated. The <pre> text is displaying in a smaller font size (and I believe different font)...
5
by: Michael Shell | last post by:
Greetings, Consider the XHTML document attached at the end of this post. When viewed under Firefox 1.0.5 on Linux, highlighting and pasting (into a text editor) the <pre> tag listing will...
8
by: Jarno Suni not | last post by:
It seems to be invalid in HTML 4.01, but valid in XHTML 1.0. Why is there the difference? Can that pose a problem when such a XHTML document is served as text/html?
7
by: Rocky Moore | last post by:
I have a web site called HintsAndTips.com. On this site people post tips using a very simply webform with a multi line TextBox for inputing the tip text. This text is encode to HTML so that no...
14
by: Schraalhans Keukenmeester | last post by:
I am building a default sheet for my linux-related pages. Since many linux users still rely on/prefer viewing textmode and unstyled content I try to stick to the correct html tags to pertain good...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...

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.