file() function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
khurram
Forum Newbie
Posts: 2
Joined: Fri Jul 11, 2003 1:40 am
Location: PAKISTAN
Contact:

file() function

Post by khurram »

twigletmac | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


hello all great programmers,

i m new to PHP. i m developed a simple page in which i use implode() function. this program was running fime when i was using php 4.3. but as i upgrade it to php 5.1 it is not working and giving error.

source is here

Code: Select all

<?php
$contents="";
include "config.php";
include "common.php";
$f="login.htm";
$contents = implode('',file($f));
$contents=formatPage($contents);
print $contents;
?>
it gives error.
Warning: file(login.htm): failed to open stream: No such file or directory in d:\www\currNs\login.php on line 7 Warning: implode(): Bad arguments. in d:\www\currNs\login.php on line 7

but when i provide its path on local machine

Code: Select all

$f="D:\www\curr\Ns\login.htm";
    $contents = implode('',file($f));
it runs fine.

what is this problem and how can i overcome this one i already waste a whole day on it..:(

pls email me gbuttgee@yahoo.com

thanks in advance

Khurram


twigletmac | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

make sure login.htm and login.php are on the same page...if not you can use relative path not necessarily absolute path...
khurram
Forum Newbie
Posts: 2
Joined: Fri Jul 11, 2003 1:40 am
Location: PAKISTAN
Contact:

Post by khurram »

yes login.htm and login.php are in the same folder. this script was running absolutly fine on php4.3

what is relative path and absolute path? :roll:

Khurram
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

This should help you...
Post Reply