emery Posted December 18, 2011 Share Posted December 18, 2011 I need to find out the length of a file, or just find out if there is a file called "abc" in the folder, if the file is not there, it errors "Cant open file" "No such file", how do i get around this Also, i have a varible, A$ A$ = "BOB" i need it to equal "'A$'.V" i tried to use A$ = A$ + ".v", it doesn't work, but it doesn't error ??? Quote Link to comment https://forums.phpfreaks.com/topic/253405-is-it-there/ Share on other sites More sharing options...
dweeber Posted December 18, 2011 Share Posted December 18, 2011 I need to find out the length of a file http://php.net/manual/en/function.filesize.php or http://php.net/manual/en/function.stat.php or just find out if there is a file called "abc" in the folder, if the file is not there, it errors "Cant open file" "No such file", how do i get around this Does file exist: http://php.net/manual/en/function.file-exists.php Search through a directory: http://php.net/manual/en/function.readdir.php Also, i have a varible, A$ A$ = "BOB" i need it to equal "'A$'.V" i tried to use A$ = A$ + ".v", it doesn't work, but it doesn't error ??? # $A = "BOB"; # $A .= ".v"; # echo $A; BOB.v Quote Link to comment https://forums.phpfreaks.com/topic/253405-is-it-there/#findComment-1298954 Share on other sites More sharing options...
emery Posted December 18, 2011 Author Share Posted December 18, 2011 Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/253405-is-it-there/#findComment-1298958 Share on other sites More sharing options...
emery Posted December 18, 2011 Author Share Posted December 18, 2011 I also cant figure out how to get this $A = "BOB" i need A$ to = "\public_html\test\BOB" Quote Link to comment https://forums.phpfreaks.com/topic/253405-is-it-there/#findComment-1298964 Share on other sites More sharing options...
trq Posted December 18, 2011 Share Posted December 18, 2011 $A = '\public_html\test\BOB'; Quote Link to comment https://forums.phpfreaks.com/topic/253405-is-it-there/#findComment-1298969 Share on other sites More sharing options...
emery Posted December 18, 2011 Author Share Posted December 18, 2011 oh, i mean that the value of A$ will change from BOB i need to place public_html\test before it Quote Link to comment https://forums.phpfreaks.com/topic/253405-is-it-there/#findComment-1298979 Share on other sites More sharing options...
manny Posted December 18, 2011 Share Posted December 18, 2011 do not use file_exists(), if $A will == '' and the directory exist, it will return true. instead use is_file(); example <?php // if you need to go back one folder use dirname(dirname(__FILE__)) // same like ../ $dir = dirname(__FILE__).'/test/'; // dirname(__FILE__) returns the absolute path for the file this is written in $a = 'BOB'; $b = $dir.$a; if(is_file($b)) { // do something... } else { // do nothing... } ?> is_file() will also make sure it is a file, and not a symbolic link or a folder, but an actual file Quote Link to comment https://forums.phpfreaks.com/topic/253405-is-it-there/#findComment-1299019 Share on other sites More sharing options...
emery Posted December 18, 2011 Author Share Posted December 18, 2011 Well, i need it to go to a diffrent folder compleatly, like the code is in /public_html/register and the files need to go in /public_html/test Quote Link to comment https://forums.phpfreaks.com/topic/253405-is-it-there/#findComment-1299033 Share on other sites More sharing options...
manny Posted December 18, 2011 Share Posted December 18, 2011 cool, then use dirname twice. like this. $dir = dirname(dirname(__FILE__)) .'/test/'; Quote Link to comment https://forums.phpfreaks.com/topic/253405-is-it-there/#findComment-1299041 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.