Jump to content

Is it there?


emery

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.