What is the best practice for correctly targeting 'include' paths
when using Initialization/Setup classes that extend Parent classes?
In my extend_parent_class.php file, I have to provide an incorrect
relative path. Apparently, the path (that does work) is relative to
php file that calls the initialization/setup class
(call_the_extend_parent_class.php). Is there a less confusing way to
correctly target include paths when creating initialization classes?
Should I be using absolute paths instead?
many thanks in advance
extend_parent_class.php:
include_once('./path/to/parent_class.php'); # Works with 'incorrect'
relative path
//include_once('../path/to/parent_class.php'); # Fatal Error with
'correct' relative path
class Initialize_Parent_Class extends Parent_Class {
function Initialize_Parent_Class()
{
$this->Parent_Class();
echo "This was successful and does not result in a fatal 'class not
found' error";
}
}
Call the initialization class.
call_the_extend_parent_class.php:
<?php
require('./includes/extend_parent_class.php'); # initialize Parent Class
$parent_class = new Initialize_Parent_Class();
// prints 'This was successful and does not result in a fatal 'class
not found' error'
?>
File structure:
php
++call_the_extend_parent_class.php
++ includes directory
++++ extend_parent_class.php
++ classes directory
++++ parent_class.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php