FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Errors Related to Same Path Through Real and Symbolic Link References
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Errors Related to Same Path Through Real and Symbolic Link References [message #178711 is a reply to message #178710] Sun, 22 July 2012 06:30 Go to previous messageGo to previous message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma:
Senior Member
On 22/07/12 05:53, SMH wrote:
> I am using "require_once" to include a PHP file that defines constants and
> commonly used functions. It is in a main script and also in support scripts
> that are themselves included in the main script. The main script is in a
> "development" directory, and that directory contains a symbolic link to
> included files. I am getting a FATAL ERROR (function in included file is
> re-declared) because there is a reference to an included script through a
> real path and one through a symbolically linked path.

The obvious solution is to see that you include the file just once.


Another work around is to use c/c++ like define checks:

<?php
if(!defined('__MYPHPFILENAME'))
{
// define the value, so next include won't come in here
define('__MYPHPFILENAME', true);

function first_function_of_yours() {
// your code here
}


function second_function_of_yours() {
// your code here
}

}
?>


or you could do for each function:

if(!function_exists('first_function_of_yours')) {
function first_function_of_yours() {
// your code here
}

}

and you have to see if values are defined before you define those (if
you use global values).


If you really want to do it the right way, just see to just include the
file once, no matter if it's the original file or a symlink.

--

//Aho
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Solution Manuals & Test Banks
Next Topic: Using PHP and JAVA applets together
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 01:46:46 GMT 2024

Total time taken to generate the page: 0.03986 seconds