Re: Test if File Exist, if not, use default file name
| From: | Alan Ward | Date: | Wed, 07 Mar 2001 01:32:18 +0000 |
| Subject: | Re: Test if File Exist, if not, use default file name | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-42838@lists.php.net to get a copy of this message | ||
Try this:
if (file_exists("filename")) { echo "Error"; }
-AL
>
> What I would like to have the script do is to check if a variable was
> passed, and to check if the file name passed actually exist. If either
> case is false then I would like to have it check if the file testQA
> exist and if so then the script would run using this test file, if not
> then the script would just terminate giving the user an error message.
> I was wondering how you would do this?
>
> Right now I have it semi-working, but it is very convoluted and if the
> variable is not passed it displays a "Warning: Undefined variable:
> questionFileName in
> c:\server\apache\htdocs\survey\questionanswer.phtml". Ideally it
> would not display this message and just check if the testQA file is
> around and if not then just terminate with an error message of my
> choice.
>
> -Thanks for any ideas,
> Andrew V. Romero
> To reply personally, remove all numbers from my address.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>