How Can I Find Out Parent (including) File Of Included File?
How can i find out parent (including) file of included file?
Lets imagine that we want to for example auto_prepend file to each file on our server that would write out the name of file its being executed. I know, i can use PHP_SELF but what if i want to write name of file which is already included?
I have a web page and i want on it show its name even if it was included, but not the included page itself is showing name but auto_prepend file to each php file, its duty of this auto_prepend_file to write it out i dont want myself to echo it on each page? do you feel me?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Problem With A File Included Twice When I Want It To Be Included Once
I have a problem with a file that apparently is being included twice when I want it to be included once. I searched all my files and couldn’t find a place in which I am not calling it with include_once("file_name") Is there a way to print or output in any way which file calls this file? It could be an included file that calls this file, so I need to know the file name, not the page name that calls this file.
Included File Not Included Every Time
I have some pages where I'm including a header for the document - beginning of the HTML, style sheet, javascript, logos etc. The problem is that sometimes it's being included and sometimes it isn't - and I'm talking even on the same page. The header file is in the same folder as the document I'm including it in, so I'm just using: PHP Code:
Is A PHP Variable Supposed To Be Seen In A .js File Included Into A .php File
Is a PHP variable supposed to be seen in a .js file included into a .php file? I have a client side javascript code stored in a .js file which is included into a PHP file using <script src="filename.js></script> This code initialises a Javascript variable var u="string"; The string is supposed to be the value of $HTTP_HOST So, when initialise this variable like var u=<? echo $HTTP_HOST;?>; I sterted getting a javascript message Syntax Error Am I doing something wrong, or PHP variables are not seen in included js files?
SSI Including PHP File Within PHP File Causes Seg Fault And Crash
Can somebody concur or verify the following? I'm having this problem on all of my installations. I've got Apache 2.0.40 and PHP 4.2.2 installed and configured from RedHat RPMs. Nothing out of the ordinary. In the httpd.conf file, PHP files are called with the following: <Files *.php> SetOutputFilter PHP;INCLUDES SetInputFilter PHP LimitRequestBody 524288 </Files> I create two files as follows: /test1.php <!--#include virtaul="/test2.php" --> and /test2.php Testing 1 2 3 By going to http://host/test1.php, it may or may not display the file contents of test2.php. Usually (9/10 times) I get a seg fault in the error log. If I change the filename of test.php to test.html and include that, it works fine. I've tried this on various versions of both Apache and PHP up to the most recent CVS versions and still get the same results.
Include File In Parent Folder
I want to include a certain file that's in a parent folder. For example, the file "config.php" is located in public_html/ and the file i'm including it in is in public_html/admin/ How do I include public_html/config.php in public_html/admin/index.php?
Check If A File Has Been Included Before?
I want my scripts to be warning and error free. Is it possible to check is a file has already been included as part of a "require", "require_once" or "include" call in the script? I guess I could just include everything and turn warnings/errors off, but I'd prefer not to do that.
Retrieving Variables From Included File
I'm trying to use a variable created in a file I'm including from within a PHP script: include("http://www.domain.com/script.php"); echo $variable; // $variable still empty? The $variable is created inside script.php but is empty when I echo it from the calling script. Is it the way I'm including the script via http? I have to do this since it's on another server.
Establishing PHP Session ID In An Included File
Forgive me if this doesn't make too much sense but I've been working on this project all day and my brain is a bit fried. To make some of my code more readable I made a file (called urls.inc) which I include in my PHP scripts. This file contains functions to return a URL with the session id tagged on the end. I've now found out that the session id returned by the functions in urls.inc is not necessarily the current, and more importantly correct, session id. I need to know if there is a way to establish the current session id within the included file. For info, I've built the scripts so that the session id is passed from page to page to avoid using cookies (part of the challenge, it's a college project) so I need the urls.inc file to know which session id to pass back otherwise it all goes a bit squiffy. Here's urls.inc : <?php session_start(); function logoutURL() { return "logout.php?PHPSESSID=" . session_id(); } function adminURL() { return "admintools.php?PHPSESSID=" . session_id(); } function homeURL() { return "main.php?PHPSESSID=" . session_id(); } ?> These are called like this : echo "<h3 align="center"><a href="" . adminURL() . "" target="mainFrame">Administration Tools</a></h3>"; If it turns out that there's no way to do what I'm after then it's not big deal because I can change the URL line to : echo "<h3 align="center"><a href="admintools.php?PHPSESSID=" . session_id() . "" target="mainFrame">Administration Tools</a></h3>";
Stopping Execution Of An Included File?
I have a structure like this: Code: /index.php /dir_1/index.php /dir_2/index.php . . /dir_n/index.php In the topmost index.php file i have a switch statement selecting the current active directory (e.g. dir_2) and including the index.php file in that dir, if it exists. Is there any way I can stop the execution of the included file (/dir_2/index.php) without affecting the calling file (/index.php)?
Getting Cookie From HTTP_COOKIE_VARS In Included File
There's this thing about cookies that's bothered me and up until now I simply got around it. I can't do it anymore right now and I need to solve this problem, so I'm asking for some help. I have used the include() function to include a few PHP bars and modules in a main PHP page. I can get cookies with the HTTP_COOKIE_VARS or $_COOKIE globals in the main page, but not in the included ones. If I open the included PHP pages as standalones, I can get the cookies. I already had tons of problems with include(), I guess this is just another one. Can anyone tell me if it is supposed to be so (PHP manual says I can access the related global from anywhere) or if there's a way to fix this. The one thing I can't do is reading the cookies from the main page and passing them to the include, because that would mean changing code for the whole site.
BOF In The Included File Shows Up In The Browser
I have an UTF-8 PHP file which generates HTML Then I cut the beginning of that file, pasted into another UTF-8 file ind included this second file into the first one. After that the whole page moved down about one libe leaving a gap at the top of the browser window. Viewing the resulting code of the first file via VIEW-Source, I and see a square inserted before the included file. This does not show if I open the included file with a Unicode supporting text editor. A non-unicode editos shows i>? at the beginning of the file which, I understand, is BOF. So the problem is that the browser sees the second BOF and displays it as a small square in a separate line
Included File Not Loading Completely
This is my first post to this list, so forgive me if this is very basic. I have a file: overview.php that is including another file dolan_header.php I have tested it on three servers...on two of them it works perfectly, and on the third (the client's server) the header file fails to load the first ~12 lines of code. A functioning version of the page is here: http://64.132.144.101/~somedom/dolan/overview.php And a malfunctioning version is here: http://dolanconcrete.com/staging/overview.php I have placed the two PHP files here if anybody should care to inspect them. http://64.132.144.101/~somedom/php/dolan_php_debug.zip
Require_once Fails If File Already Included
I am having a problem with multiple includes. A.php require_once on two files: B.php then C.php C.php require_once on B.php again Then I get a message: Warning: main(../../B.php): failed to open stream: No such file or directory in /home/jkennedy/public_html/foo/php/secure/common/A.php on line 1 Fatal error: main(): Failed opening required '../../B.php' (include_path='/home/jkennedy/public_html/foo/php/secure:/usr/share/php:/usr/share/php/Smarty-2.6.2/libs:/home/jkennedy/public_html/foo/_php/secure/PEAR') in /home/jkennedy/public_html/foo/php/secure/common/A.php on line 1 If I comment out the second require_once of B.php in C.php, the error goes away and I still get the variables defined in B.php, so I know it is being included. My question is why is it failing in the manner that it is doing? From what I could tell in the manual require_once was supposed to do nothing if it was already included. And why the "Failed opening", as if the file didn't exist? I am using PHP 4.3.4.
Including A File
I am attempting to include a file, but it is not working so well. Here is my direcoty structure. Root |-/file_man |-/functions | |-/index | |- top.x |-/files |-/users |-index.php I am trying to call top.x from index.php using require, but it doesnt work like this require("/file_man/functions/index/top.x"); any thoughs?
Printing The Line Number And Name Of Included File
Does anyone know how to echo the line number and included file name in php. I like to use development tags but sometimes I forget what included file they are in and what line they are on. I use a master variable to turn off all of the dev tags, but I would really like an easy way to automatically print the line number and file where the function is. This would be like if there was an error, but with out breaking the script and with out generating a nasty error.
Getting An Included PHP Script To To Include A File In The Same Directory.
I am a little stumped at why when I try to include a file in same directory as the script being processed, it looks in the same directory as the script that included it to begin with. Is there any way I can get around this? Is there anyway to get the name and/or of the script being processed, rather than the name and/or path of the script that was first called?
Problem Including The Other Php File.
I want to include three php files in index.php file like the code below. But it always shows up only two, any two of the three, any order. <tr> <td><?php include ("includes/documents.php"); ?> </td> </tr> <tr> <td><?php include ("includes/locations.php"); ?> </td> </tr> <tr> <td><?php include ("includes/status.php"); ?> </td> </tr> Can anyone help me out?
Including External File
I have two sites that I am trying to get to "talk" to each other. I have one site that contains a PHP file that basically outputs an XML formatted list depending on the file structure in that directory. The other site needs this XML formatted data to complete the PHP generated XML file that I am trying to put together. (Much like syndicating my content from one site to another) I have tried using readfile, include and header(Location:) and none of them seem to be working. What I need is for the calling file to somehow include the output of the remote file. (The same stuff you see if you view the source) What happens is that I can 'readfile' my index page on that site, but not the one that puts out the XML data that I need. Could it be that the XML file doesn't actually create any visual content on the page? or doesn't have 'head' and 'body' tags? It would be great if I could do all of this in PHP so that the final source would not include anything that would disrupt the final XML output.
Including Txt Html File
I'm converting all my pages to php from shtml files. How can I include the txt files for different parts of the site using php rather than using the includes that I had before? The text file that I'm using is for the menu and in the text file is all the html for the menu.
Including A .php File From Another Server?
I am trying to include a function in a .php file on a different server from the main .php files. I am using: include_path=http://www.anotherserver.com/foldername; include(http://www.anotherserver.com/folder...iletocall.inc); The .inc file is php formatted. Variables are passed to it (not via GET or POST though) and returned using return(variablenames, etc); But for some reason it doesn't appear to work properly. Am I correct in using the .inc extension? Are the commands above correctly written? Basically I am trying to use the fsockopen function in a .php file on another server where I know it works and return the results to a server where the fsockopen command doesn't work.
Including A File In Another Frame
I've the following code: mainpage.php ---------------------------- <FRAME name="framesuperior" src="framesuperior.php?a_caller=inicio"> <FRAME name="framecatalogo" src="frameinferior.php?a_caller=inicio"> ---------------------------- framesuperior.php ---------------------------- $a_caller = $_GET['a_caller']; $a_dhn = $_GET['a_dhn']; if ($a_caller=="menuprincipal"){ //this file could be called from another files include("menusecundario.php"); //this line will update framesuperior.php ***** Here I need to include "file.php" but in "framecatalogo" frame }
Only Including Certain File Types
I have this code which i have taken from php.net and am hopin to have someone tell me how i could modify it to display only one file type (.mid) also this is to stop the script from displaying other directorys as they will automatically load up the index of that directory and won't display a list. <? $the_array = Array(); $handle = opendir('/home/www/juttuffi/midi/files'); while (false!== ($file = readdir($handle))) { if ($file!= "." && $file!= "..") { $the_array[] = $file; } } closedir($handle); sort ($the_array); reset ($the_array); while (list ($key, $val) = each ($the_array)) { echo "<a href=http://example.co.uk/midi/files/$val target=_blank>$val</a><br>"; } ?>
Problem Including File (intermediate)
I wonder if someone can help me, I've set my web site up as follows: There is a 'services' page that displays .html pages in a sub-dir when specified in the URL. I need use the switch function as the code following shows: <?php if(isset($_GET['p'])) { switch ($_GET['p']) { // include ('test.inc'); case "test": include "./services/test.html"; break; case "2test2": include "./services/2test2.html"; break; default: } } else { echo "<p><br><br><B>Please choose a topic from the left</B></p> "; } ?> Basically.. I want to use the include(test.inc) file which contains the two lines of code following it. But I get an error: Parse error: parse error, expecting `T_CASE' or `T_DEFAULT' or `'}'' in /home/rmgraphics/public_html/services.php on line 27 - which is the include page line and I've commented out for now I need to use the test.inc file for the case lines because I want to manage the list by opening the file direct.
Including File And Output To Browser
I am not sure I understand the rules as to what exactly gets output to a browser and when. If I include a text only file or an html file, these will show up in the browser regardless of where in the script they are included.
Including Database Config File
I'm facing a problem with including the database config file.. I kept database variables in a config file like this.. connect.php <?php $dbhost='something' $dbuser='something' $dbpass='something' $dbname='something' ?> then in my home.php file I've included that file ( both connect.php and home.php are in same folder ); <?php include 'connect.php' $db=mysql_connect($dbhost,$dbuser,$dbpass); mysql_select_db($dbname,$db); //some actions ?> The above thing worked fine until I moved the config file to root directoryso that It will be available to all scripts.. the changes I've made to the script.. home.php <?php include 'http://domain.com/connect.php' $db=mysql_connect($dbhost,$dbuser,$dbpass); mysql_select_db($dbname,$db); //some actions ?> the above code this throwing errors..
Including A Standard File In All Directories
I have one layout page that all directories use on my website. How can I make it so that no matter where the file is, the server will always include it. I cannot use direct paths because php will not allow it, and I can't specify the directory for each file. Example. Layout.php includes files/header.php which includes lib/main.lib. in Pages/Path/index.php I include ../../Layout.php. Than Layout.php's includes are all messed up.
Including An Html File In Php Script
how would i include a file that contained all the html code for the display of a webpage in a php fifle so that i dont have to clutter the php with the html.
Database Connection Problem In Included File On Root Directory
I have a file called tophtml.php that connects to the database. It's in the root directory of the site. It works perfect in the root directory. But if I call it in a sub directory. (e.g. require("../tophtml.php") or require("C:websitesdogrealm ophtml.php")) I get errors saying it can't connect to the database.
Including A File (redirecting Using Header Command)
When including a file in the script or redirecting using header command, for example, should I use a file path: ../../x.php or ab/cd/x.php say cd and ab are previously defined as constants that are the names of immediate parent directory and grandparent directory respectively, which one is better in design, using .. or using constants?
Cannot Find In Any Of The Linked Libraries Including Libmysql.dll
Was wondering if the mysql api (mysql_thread_end) comes with support for PHP. I have tried using both php_mysql.dll and php_mysqli.dll (also obviously libmysql.dll) and both of them from a test and dcoumentation standpoint doesnot support most of the threaded function calls. This call apparently needs to be executed when apache starts with ph p configured for mysql support (i.e. apache WHENEVER apache loads up php_mysql.dll AND/OR php_mysqli.dll it verifies the mysql_thread_end call and cannot find in any of the linked libraries including libmysql.dll).
File Which Tries To Find Itself And Can't...
<? //file test.php phpinfo(); $filename = "test.php";//it does not work $filename = $_SERVER['DOCUMENT_ROOT']."/home/ke000067/public_html/test.php"; //it does not work $filename = $_SERVER['DOCUMENT_ROOT']."/~ke000067/public_html/test.php"; //it does not work $filename = "home/ke000067/public_html/test.php"; //it does not work echo 'fila buscada: '.$filename.'<br>' if (file_exists($filename)) { echo 'Of course it is.<br>' }else{ echo 'What?? How can it be???.<br>' } ?> these are some values retieved from phpinfo _ENV["REMOTE_PORT"]2010 _ENV["SCRIPT_FILENAME"]/home/ke000067/public_html/test.php _ENV["SCRIPT_URI"]http://200.50.110.233/~ke000067/test.php _ENV["SCRIPT_URL"]/~ke000067/test.php _ENV["SERVER_ADDR"]200.50.110.233 _ENV["SERVER_NAME"]200.50.110.233 _ENV["SERVER_PORT"]80 _ENV["SERVER_SIGNATURE"]<ADDRESS>Apache/1.3.33 Server at 200.58.112.233 Port 80</ADDRESS> _ENV["SERVER_SOFTWARE"]Apache/1.3.33 (Unix) mod_auth_passthrough/1.8 mod_bwlimited/1.4 mod_log_bytes/1.2 mod_ssl/2.8.22 OpenSSL/0.9.7e FrontPage/5.0.2.2635 _ENV["GATEWAY_INTERFACE"]CGI/1.1 _ENV["SERVER_PROTOCOL"]HTTP/1.1 _ENV["REQUEST_METHOD"]GET _ENV["REQUEST_URI"]/~ke000067/test.php _ENV["SCRIPT_NAME"]/~ke000067/test.php _ENV["PATH_TRANSLATED"]/home/ke000067/public_html/test.php I'm really confused about paths. Now I think that it is not a good idea to learn on local server, beacause whenever one changes to a shared one, all seems to fail....
File Find Question
I looked in the manual and searched the web but did not see a file find function that takes a wild card - I need to look for all files such as: $Array = FileFind('name_*.jpg'); And then I need to delete all such files. Is there such a function?
$PHP_SELF To Find Out The Name Of File Itself.
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...
HOw Can I Find Out File Size ?
How can i find out the file size of a folder present in site root folder. for example : /-- | [ram] #folder Now i want to know the file size of this folder call (ram) in site root folder. Actu. I want to display the folder size in my page.
Path Getting Messed Up - Cannot Find A File
If I run the following code: exec ("swetest -edir$sweph -b$utdatenow -ut$utnow -p012 -eswe -flsj -g, -head", $out); all is well - PHP finds the program swetest and makes the calculations. But if I then insert this beforehand: $NetGeoHTML = file_get_contents($NetGeoURL, 99000); exec ("swetest -edir$sweph -b$utdatenow -ut$utnow -p012 -eswe -flsj -g,...
Loop Through Array Find File Extension
i need to build a little script for my browser script... i need to do the following... extract the .ext from the given file name, then i need to pass that to an array that has a list of valid extensions and what icon to use.
Where Can I Find The GD Library Standalone Executable File?
I downloaded the tarball and while was able to compile within PHP with no problems, I am having memory timeout issues involving image manipulation with extremely large images (800K - 2mb). Requirements are to create thumbnails for even these banner-sized images, but PHP + GD + [huge image] = too much memory. I'm trying to prove that it is undoable, though the suggestion was to do a command-line GD call to the image instead of using the PHP functions to do so to save some memory; if it still times out, then it's undoable altogether. However, I cannot find the standalone executable file that will ensure I can run GD from the command line.
IIS Could Not Find .php File, However It Finds Html Files In The Same Dir
IIS could not find .php file, however it finds html files in the same dir..... http://localhost/test => the default.htm will be hit, no error http://localhost/test/test.php => 404 error not found( it exists in the dir) The security is set ok, something wrong with the php runtime?? Strange because my application on localhost/prog works smooth.........
Fput Function (Warning: Unable To Find File Identifier 0 In)
I made a script for logging the emails that they send on my site. It works fine on windows 98 version, but when I upload it to a Linux computer it fails. Here are the first lines of the script: $file = fopen("log/index.html", "a+"); $today = date("G:i, l jS Y"); if ($argv[0] == "contact"){ if ($name == ""){ fputs($file, "Text comes here"; fclose$file);} Then the output is: Warning: fopen("log/index.html","a+") - Permission denied in /home/jonathan/public_html/beftubbies/email.php3 on line 3 Warning: Unable to find file identifier 0 in /home/jonathan/public_html/beftubbies/email.php3 on line 30
How To Find Full Path Of A File Upload Field In A Form?
I need a way to find the full path of a file uploaded by file upload form box. $_FILES['file1']['name'] gives just file name. I have a file upload form and if the user submitted something wrong I want the page to go back and have the forms maintain its values (the full path to local file, e.g: "c:/docs/landscape.jpg"). Any way to do that? This is a more complex applications so using another upload tool is not an option.
Value Of Variable Shown As "Array" When From Included File
I have this statement to find the latest date that a row was inserted ________ $entry=mysql_query("SELECT contact FROM board ORDER BY contact DESC LIMIT 1")or die ("Query failed:<br>$entry<br>Error: " . mysql_error()); while($myrow=mysql_fetch_array($entry)){ if (ISSET($myrow['contact'])){ $latest = date("d M y", ($myrow['contact']+50400)); } } ________ This reports the value for $latest correctly if the statement is in the document. However when the statement is in an included file the reported value for $latest is ... Array Where am I going wrong?
PHP 4: Does Method_exist Return True If Parent Class Method Even If Child Class Forgot To Call Parent::
My code was dying on the line below where I use method_exists: if (class_exists($nameOfClassToBeUsed)) { $object = new $nameOfClassToBeUsed(); $this->arrayOfAllTheObjectsSoFarLoaded[$nameOfClassToBeUsed] = & $object; if (method_exists($object, "setCallingCode")) $object->setCallingCode($nameOfFunctionOrClassCalling); return $object; } else { $this->error("$nameOfClassToBeUsed not found. The code that wants this class is $nameOfFunctionOrClassCalling "); } The method is in the parent class yet I'd forgotten to call parent:: in the constructor of the child class. It seems to me that method_exists was testing true, though the method was not truly available, and then the code died. Adding parent:: to the constructor of the child solved the problem. Is this a bug in PHP?
To Get A File Name, File Size, File Type...?
Is there a way to get information about a file BEFORE it is submitted to the server? I am trying to make a upload progress bar from scratch WITHOUT THE PRON.C PHP FIX!!! I found the file being uploaded in my NET://WINN01910//TEMP folder and I can outputs its file size in a popup with a one second refrehs, but this makes it so the USER needs to know the full file size to know if its anywehre near done. Is there a way to get the filesize from the clients side? Possibly javascript that uses ajax to submit the values to the server before the file is sent but when it is selected?? Is there an easier way to do this and/or do you have any ajax example code of how it might work? I also have another problem, Althoguh i can echo the filesize of what is recieved so far, I am just glob()ing the temp folder for: "php*.tmp" but is there a way to tell the tmp file so they don't see everyone's uploads?
FIle Uploads: Empty _POST And _FILES Arrays When File Too Large
Uploading of files.. AFAIU from the manual, if a file is larger than the size defined in the form or larger than upload_max_filesize in php.ini, that _FILES['file']['error'] should hold an INT error code. The file upload system is working fine if the file is smaller than the defined size, but if it's larger, then both the _POST and _FILES arrays are completely empty: array(0) { } I can obviously check to see if $_FILES is set and contains elements, but I was hoping for more specific error handling (reason as to why the upload failed). Has anyone else encountered this? Any info welcomed =)
|