pk-uk Posted January 10, 2008 Share Posted January 10, 2008 Here is the code: $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 "; } else { echo "The file $filename does not exist "; } $ipath = get_include_path() ; echo "The include path is: $ipath " ; if ((require '/usr/local/psa/home/vhosts/sub.some_site.co.uk/httpdocs/smarty/libs/Smarty.class.php') == "OK" ) {require '/usr/local/psa/home/vhosts/sub.some_site.co.uk/httpdocs/smarty/libs/Smarty.class.php' ; echo "Include worked" ;} else {echo 'Failed to include' ; } and this is the output: The file /usr/local/psa/home/vhosts/sub.some_site.co.uk/httpdocs/smarty/libs/Smarty.class.php exists The include path is: .: Failed to include Any help greatly appreciated. PHP is v5.2.1 Quote Link to comment Share on other sites More sharing options...
drummer101 Posted January 10, 2008 Share Posted January 10, 2008 Have you set the include path in your php.ini? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted January 10, 2008 Share Posted January 10, 2008 if ((require '/usr/local/psa/home/vhosts/sub.some_site.co.uk/httpdocs/smarty/libs/Smarty.class.php') == "OK" ) Would that be true? I don't think require returns a value. Quote Link to comment Share on other sites More sharing options...
psychowolvesbane Posted January 10, 2008 Share Posted January 10, 2008 Shouldn't $filename = '/usr/local/psa/home/vhosts/sub.some_site.co.uk/httpdocs/smarty/libs/Smarty.class.php' ; be: $filename = "/usr/local/psa/home/vhosts/sub.some_site.co.uk/httpdocs/smarty/libs/Smarty.class.php" ; ?? Isn't it "" quotes for text and ' ' for numbers right? Quote Link to comment Share on other sites More sharing options...
trq Posted January 10, 2008 Share Posted January 10, 2008 Shouldn't $filename = '/usr/local/psa/home/vhosts/sub.some_site.co.uk/httpdocs/smarty/libs/Smarty.class.php' ; be: $filename = "/usr/local/psa/home/vhosts/sub.some_site.co.uk/httpdocs/smarty/libs/Smarty.class.php" ; ?? Isn't it "" quotes for text and ' ' for numbers right? No, string can be within single or double quotes, numbers (integers) should never be surrounded by quotes. require does not return the string "OK". Your test is faulty. Have you tried actually using the Smarty class your including? Given an absolute path like that there is no reason why require won't work. Quote Link to comment Share on other sites More sharing options...
drummer101 Posted January 10, 2008 Share Posted January 10, 2008 Isn't it "" quotes for text and ' ' for numbers right? $strings don't parse correctly inside single quotes, however including them in double quotes, is slower to parse. Quote Link to comment Share on other sites More sharing options...
drummer101 Posted January 11, 2008 Share Posted January 11, 2008 $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 "; } else { echo "The file $filename does not exist "; } Is correct, however, the last part is just :? after the above code, just either include() or require() your file, and go from there. Quote Link to comment Share on other sites More sharing options...
pk-uk Posted January 11, 2008 Author Share Posted January 11, 2008 Thanks guys - appreciate the help. (1) no, I didn't set the path name in php.ini - I don't have access and don't want to over-ride. (2) The == OK bit should work, I think. See example 4 here: http://uk3.php.net/manual/en/function.include.php Nevertheless, given the reply above I removed it and have got it to work - sort of. By that I mean I have included a file, but now have problems with an include embedded in another include. However, this has made my head hurt and it's past midnight here. I'll investigate tomorrow. Thanks again for very prompt attention. Quote Link to comment Share on other sites More sharing options...
trq Posted January 11, 2008 Share Posted January 11, 2008 (2) The == OK bit should work, I think. See example 4 here: http://uk3.php.net/manual/en/function.include.php That example demonstrates the file being included returning the value "OK", not the call to include itself. Quote Link to comment Share on other sites More sharing options...
pk-uk Posted January 11, 2008 Author Share Posted January 11, 2008 (2) The == OK bit should work, I think. See example 4 here: http://uk3.php.net/manual/en/function.include.php That example demonstrates the file being included returning the value "OK", not the call to include itself. .... which is what I'd thought I'd done: if ((require '/usr/local/psa/home/vhosts/sub.some_site.co.uk/httpdocs/smarty/libs/Smarty.class.php') == "OK" ) How should I have coded it? Is there a significance in my use of double, rather than single quotes? Retrospectively it seems that that's the only fundamental difference between my code and the example (barring I'm using require rather than include - though, the manual says they are fundamentally the same). I ask because I'm not that experienced in the use of PHP and often get into a muddle with the concepts Thanks Quote Link to comment Share on other sites More sharing options...
trq Posted January 11, 2008 Share Posted January 11, 2008 Does the Smarty.class.php file have the line... return "OK"; in it? That is what that example demonstrates. Quote Link to comment Share on other sites More sharing options...
pk-uk Posted January 12, 2008 Author Share Posted January 12, 2008 Does the Smarty.class.php file have the line... return "OK"; in it? That is what that example demonstrates. Aha Thanks for the lesson - appreciated Quote Link to comment 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.