Re: [PHP] FileExists?
On Mon, November 7, 2005 1:45 pm, Gustav Wiberg wrote: > File_exists doesn't seem to work with URLs that point to another > domain. > What to use? > > $x = fopen(http://www.stammis.com/getstart.php); There are no quotes on that URL... I'd be surprised if this doesn't error out, but maybe you just need E_ALL to see the E_NOTICE you've been ignoring. At any rate, you need quotes, whether you realize it or not. > if file_exists($x) $x, at this point, is either FALSE because fopen() failed, or an open file handle. file_exists() expects the path to a file name (a string). Perhaps you meant: file_exists("http://www.example.com";); http://php.net/file_exists specifically links to the kinds of stream-wrappers that are and aren't supported. Did you read that? -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] FileExists?
Gustav Wiberg wrote: - Original Message - From: "M" <[EMAIL PROTECTED]> To: "Gustav Wiberg" <[EMAIL PROTECTED]> Sent: Monday, November 07, 2005 11:12 PM Subject: Re: [PHP] FileExists? Gustav Wiberg wrote: Hi there! File_exists doesn't seem to work with URLs that point to another domain. What to use? $x = fopen(http://www.stammis.com/getstart.php); if file_exists($x) file_exists() takes filename as parameter, not file pointer. besides, spare the one http request and use @fopen() (@ will suppress eventual warning), it will speed up your script. I tested to use @fopen instead of fopen and it took 1 second longer... I meant using: if(($x = @fopen('http://www.stammis.com/getstart.php')) !== false) { } instead of: if(file_exists('http://www.stammis.com/getstart.php')) { $x = fopen('http://www.stammis.com/getstart.php'); } And you need to check the speed more than once. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] FileExists?
Gustav Wiberg wrote: Hi there! File_exists doesn't seem to work with URLs that point to another domain. What to use? $x = fopen(http://www.stammis.com/getstart.php); if file_exists($x) file_exists() takes filename as parameter, not file pointer. besides, spare the one http request and use @fopen() (@ will suppress eventual warning), it will speed up your script. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] FileExists?
Gustav Wiberg wrote: $x = fopen(http://www.stammis.com/getstart.php); if file_exists($x) That wouldn't work on a normal file either. You should always try to reduce your problem to the simplest case. :-) http://php.net/file_exists The argument is a filename. Hope that helps. Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] FileExists?
On Mon, 2005-11-07 at 20:45 +0100, Gustav Wiberg wrote: > Hi there! > > File_exists doesn't seem to work with URLs that point to another domain. > What to use? > > $x = fopen(http://www.stammis.com/getstart.php); > if file_exists($x) You are trying to check if a file pointer exists. You want to check if the file exists. Try: if( file_exists( "http://www.stammis.com/getstart.php"; ) ) -- Jasper Bryant-Greene General Manager Album Limited e: [EMAIL PROTECTED] w: http://www.album.co.nz/ b: http://jbg.name/ p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303 a: PO Box 579, Christchurch 8015, New Zealand -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] FileExists?
- Original Message - From: "Jay Blanchard" <[EMAIL PROTECTED]> To: "'Gustav Wiberg'" <[EMAIL PROTECTED]>; "PHP General" Sent: Monday, November 07, 2005 9:02 PM Subject: RE: [PHP] FileExists? [snip] File_exists doesn't seem to work with URLs that point to another domain. What to use? $x = fopen(http://www.stammis.com/getstart.php); if file_exists($x) [/snip] What version of PHP are you using. With anything less than PHP5 you cannot use file_exists on anything other than the file system PHP is local to. All versions of PHP. Explicitly using file:// since PHP 4.3.0 /path/to/file.ext relative/path/to/file.ext fileInCwd.ext C:/path/to/winfile.ext C:\path\to\winfile.ext \\smbserver\share\path\to\winfile.ext file:///path/to/file.ext file:// is the default wrapper used with PHP and represents the local filesystem. When a relative path is specified (a path which does not begin with /, \, \\, or a windows drive letter) the path provided will be applied against the current working directory. In many cases this is the directory in which the script resides unless it has been changed. Using the CLI sapi, this defaults to the directory from which the script was called. Hi I'm using PHP 4.3.0. Thanx! :-) /G http://www.varupiraten.se/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] FileExists?
[snip] File_exists doesn't seem to work with URLs that point to another domain. What to use? $x = fopen(http://www.stammis.com/getstart.php); if file_exists($x) [/snip] What version of PHP are you using. With anything less than PHP5 you cannot use file_exists on anything other than the file system PHP is local to. All versions of PHP. Explicitly using file:// since PHP 4.3.0 /path/to/file.ext relative/path/to/file.ext fileInCwd.ext C:/path/to/winfile.ext C:\path\to\winfile.ext \\smbserver\share\path\to\winfile.ext file:///path/to/file.ext file:// is the default wrapper used with PHP and represents the local filesystem. When a relative path is specified (a path which does not begin with /, \, \\, or a windows drive letter) the path provided will be applied against the current working directory. In many cases this is the directory in which the script resides unless it has been changed. Using the CLI sapi, this defaults to the directory from which the script was called. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] FileExists?
Gustav Wiberg wrote: Hi there! File_exists doesn't seem to work with URLs that point to another domain. What to use? $x = fopen(http://www.stammis.com/getstart.php); if file_exists($x) what errors are you getting? what is $x? ??? /G http://www.varupiraten.se/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] FileExists?
Hi there! File_exists doesn't seem to work with URLs that point to another domain. What to use? $x = fopen(http://www.stammis.com/getstart.php); if file_exists($x) /G http://www.varupiraten.se/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php