473,320 Members | 2,117 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

weird error with file() and implode()

Maybe I don't understand how to use this yet, but I was using (example):

$html = implode('', file('http://www.mysite.com/transbar.html'));
echo $html;
This works.

But if I try it on a .php file:
$html = implode('', file('http://www.mysite.com/transbar.php'));

I get this error:

Warning: file("http://www.mysite.com/transbar.php") - Success in
/home/cust1/usr2345/html/setuptransbar.php on line 47

Warning: Bad arguments to implode() in
/home/cust1/usr2345/html/setuptransbar.php on line 47
Can't you read in a php file this way?

Thanks,
--
Stephen Kay
Karma-Lab sk@karma-lab.NOSPAM.com
^^^^^^^
Mar 29 '06 #1
4 1584
Stephen Kay wrote:


$html = implode('', file('http://www.mysite.com/transbar.php'));

I get this error:

Warning: file("http://www.mysite.com/transbar.php") - Success in
/home/cust1/usr2345/html/setuptransbar.php on line 47

Warning: Bad arguments to implode() in
/home/cust1/usr2345/html/setuptransbar.php on line 47
Can't you read in a php file this way?


Apparently not - I presume the script doesn't generate any output and you
really want the source?

C.

Mar 29 '06 #2
i agree that the script may not be genarating any output. you check it
doing this:

echo '<pre>'; print_r(file('http://www.mysite.com/transbar.php')); echo
'</pre>';

it shows up the array you got from this request. however you won't be
able to read the source once you're making a http request.

and if you want the output as a string you should use
file_get_contents().

Mar 29 '06 #3
in article 11**********************@t31g2000cwb.googlegroups. com,
di*****@gmail.com at di*****@gmail.com wrote on 3/29/06 5:37 PM:
and if you want the output as a string you should use
file_get_contents().


Thanks, I would if my ISP was using PHP >= 4.3. It's using 4.1.
--
Stephen Kay
Karma-Lab sk@karma-lab.NOSPAM.com
^^^^^^^
Mar 29 '06 #4

I'm wondering if there is any advantage one way or the other to these two
methods of reading an html file:

1. using fopen and friends:

$myFile = "http://www.example.com/page.html";
$fh = fopen($myFile, 'r');
$content1 = fread($fh, filesize($myFile));
fclose($fh);
2. using imploed, and file:

$content1 = implode('', file("http://www.example.com/page.html"));
They both seem to work equally well, but the number 1. seems to be more
robust with different file types...
Note: I can't use file_get_contents() because my ISP's PHP version is 4.1 or
so.
--
Stephen Kay
Karma-Lab sk@karma-lab.NOSPAM.com
^^^^^^^
Mar 29 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: DesignGuy | last post by:
For lack of a better term I wish to collapse a data file as so: 03/01/04|item1|3081||| 03/01/04|item2|2081||| 03/01/04|item3|1195||| 03/01/04|item1||556|| 03/01/04|item2||450||...
3
by: Ian Davies | last post by:
I have the following code which displays some some formatted text in my browser. The problem is I need to create a text file and write the records from this array into it. Does anyone know how to...
0
by: Alan Silver | last post by:
Hello, I have two weird problems here. I have a master page file that works absolutely fine. When I load it up in VWD, I get a couple of weird (to me) errors. First, I get the error...
4
by: Gary | last post by:
Hi, I get this error " " when my web page run, what does it mean? Hope someone can help!!! Gary
0
by: P Pulkkinen | last post by:
Dear all, sorry, i know this code is far little too long to debug here, but there is really annoying logical error. If someone debugs this, I really offer warm virtual handshake. What this...
1
by: programming | last post by:
Hi all, i am having trouble trying to write a script to a txt file. I am attempting to seperate each posted item with the deliminater '|', but for some reason i am getting the following...
0
by: robin1983 | last post by:
Hi, i have a code to download the data from database to excel file. The problem is that, everything is working fine. But, actually with my code, the field name is not coming. I want to download the...
4
by: nickyspace | last post by:
HI all I have a little issue with this php code. Below is the code CODE: PHP 1.<?
1
by: RYKLOU | last post by:
I am kinda new to php, but i do know what i am doing kinda, but i came across this error when i am trying to upload a file to my website. Fatal error: Allowed memory size of 8388608 bytes...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.