Hello,
got a question.
I want to check with php if an external file exists. there are several ways to do this.
the thing is that if you use something like this, for example:
$url_parts = @parse_url( $link );
Normally the @ will hide any php errors. but with modx it will output a modx error report.
Is there a way to avoid this errors of modx or does anyone know howto check in a proper way if an external file exists?
Greetz Pieter...!
Try this:
<?php
$link="path/to/file";
if(file_exists($link)){
include_once($link);
// or
include($link);
}
?>
thanks breezer for your reaction!
but.. isn’t file_exists only to check for files on the local server?
-
☆ A M B ☆
- 24,524 Posts
Check the reader comments here, there are quite a number of solutions for this.
http://www.php.net/file_exists
I’ve tried them all!
There seem to be ervery time the same problem: modx returns a php error if the external file not exists. normaly your can avoid a php error report by adding a @ before the function, but the @ doesn’t work in modx.
thanks dev_cw, but unfortunatly I don’t use php5.