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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.