pk-uk Posted January 11, 2008 Share Posted January 11, 2008 This appears to work: $ipath = get_include_path() ; echo "The include path is: $ipath " ; $filename = '/usr/local/psa/home/vhosts/sub.some_site.co.uk/httpdocs/smarty/libs/Smarty.class.php' ; if (file_exists($filename)) { echo "The file $filename exists <br />"; } else { echo "The file $filename does not exist <br />"; } require '/usr/local/psa/home/vhosts/sub.some_site.co.uk/httpdocs/smarty/libs/Smarty.class.php' ; $smarty = new Smarty; $smarty->compile_check = true; $smarty->debugging = true; $smarty->assign("Name","Fred Irving Johnathan Bradley Peppergill"); However, this doesn't (and I want it to!) $ipath = get_include_path() ; echo "The include path is: $ipath<br />" ; $filename = '/usr/local/psa/home/vhosts/sub.some_site.co.uk/httpdocs/inc/php.inc.php' ; if (file_exists($filename)) { echo "The file $filename exists<br />"; } else { echo "The file $filename does not exist<br />"; } require '/usr/local/psa/home/vhosts/sub.some_site.co.uk/httpdocs/inc/php.inc.php' ; // $smarty = new Smarty; $smarty->compile_check = true; $smarty->debugging = true; $smarty->assign("Name","Fred Irving Johnathan Bradley Peppergill"); It results in a failure on the last line: Fatal error: Call to undefined method stdClass::assign() in /usr/local/psa/home/vhosts/sub.some_site.co.uk/httpdocs/smarty/demo/index.php on line 21 The included file contains: $site_root = $SERVER["HTTP_HOST"] . "/" ; echo " site root: $site_root<br />" ; define ('SMARTY_DIR', '/usr/local/psa/home/vhosts/sub.some_site.co.uk/httpdocs/smarty/libs/'); echo 'Smarty Dir: ' . SMARTY_DIR . '<br />' ; $filename = SMARTY_DIR . 'Smarty.class.php' ; if (file_exists($filename)) { echo " The file $filename exists<br />"; require (SMARTY_DIR . 'Smarty.class.php'); $Smarty = new Smarty ; } else { echo " The file $filename does not exist<br />"; } and the resultant trace displays: The include path is: .: The file /usr/local/psa/home/vhosts/sub.some_site.co.uk/httpdocs/inc/php.inc.php exists site root: / Smarty Dir: /usr/local/psa/home/vhosts/sub.some_site.co.uk/httpdocs/smarty/libs/ The file /usr/local/psa/home/vhosts/sub.some_site.co.uk/httpdocs/smarty/libs/Smarty.class.php exists Again, any help gratefully appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/85594-solved-further-problem-with-require/ Share on other sites More sharing options...
drummer101 Posted January 11, 2008 Share Posted January 11, 2008 require() is a function, it needs parenthesis change require '/usr/local/psa/home/vhosts/sub.some_site.co.uk/httpdocs/smarty/libs/Smarty.class.php' ; to require ('/usr/local/psa/home/vhosts/sub.some_site.co.uk/httpdocs/smarty/libs/Smarty.class.php'); Quote Link to comment https://forums.phpfreaks.com/topic/85594-solved-further-problem-with-require/#findComment-436810 Share on other sites More sharing options...
trq Posted January 11, 2008 Share Posted January 11, 2008 require() is a function, it needs parenthesis change require '/usr/local/psa/home/vhosts/sub.some_site.co.uk/httpdocs/smarty/libs/Smarty.class.php' ; to require ('/usr/local/psa/home/vhosts/sub.some_site.co.uk/httpdocs/smarty/libs/Smarty.class.php'); require is not a function, but a language construct. And no, it does not need parenthesis around its arguments. Quote Link to comment https://forums.phpfreaks.com/topic/85594-solved-further-problem-with-require/#findComment-436862 Share on other sites More sharing options...
trq Posted January 11, 2008 Share Posted January 11, 2008 You define the smarty object as $Smarty, then proceed to use $smarty in your code. Quote Link to comment https://forums.phpfreaks.com/topic/85594-solved-further-problem-with-require/#findComment-436864 Share on other sites More sharing options...
drummer101 Posted January 11, 2008 Share Posted January 11, 2008 require is not a function, but a language construct. And no, it does not need parenthesis around its arguments. Errr my bad Quote Link to comment https://forums.phpfreaks.com/topic/85594-solved-further-problem-with-require/#findComment-436872 Share on other sites More sharing options...
pk-uk Posted January 12, 2008 Author Share Posted January 12, 2008 You define the smarty object as $Smarty, then proceed to use $smarty in your code. Hmmm... always so obvious, when someone points it out to you Thanks so much - sometimes the obvious is not always so obvious Quote Link to comment https://forums.phpfreaks.com/topic/85594-solved-further-problem-with-require/#findComment-437227 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.