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 ??? 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 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! 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" 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'; 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 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 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 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/'; Link to comment https://forums.phpfreaks.com/topic/253405-is-it-there/#findComment-1299041 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.