Opening up file for inclusion in PHP -
this piece of code:
$filepath = __dir__.'/code_twitter_common_config.php'; echo $filepath;
produces following:
/users/mine/google drive/php/parnassus/public_html/apps/code/twitter/code_twitter_common_config.php
this piece of code:
if (file_exists($filepath)) { echo 'file exists'; } else { echo 'file not exist'; }
produces:
file exists
this piece of code:
$string = file_get_contents($filepath); echo $string;
produces nothing (no error codes... nothing).
i tried doing:
$string = file_get_contents("\"".$filepath."\""); echo $string;
which produced:
warning: file_get_contents("/users/mine/google drive/php/parnassus/public_html/apps/code/twitter/code_twitter_common_config.php"): failed open stream: no such file or directory in /users/mine/google drive/php/parnassus/public_html/apps/code/twitter/itb_statuses.php on line 19
i checked file permissions, , entire google drive folder set 0777. ideas? local mac.
if want execute code in file, use
include($filepath);
if want display contents of file, use:
$string = file_get_contents($filepath); echo htmlentities($string);
Comments
Post a Comment