473,773 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.p hp on line 47

Warning: Bad arguments to implode() in
/home/cust1/usr2345/html/setuptransbar.p hp 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 1607
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.p hp on line 47

Warning: Bad arguments to implode() in
/home/cust1/usr2345/html/setuptransbar.p hp 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('h ttp://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_conten ts().

Mar 29 '06 #3
in article 11************* *********@t31g2 00...legr oups.com,
di*****@gmail.c om at di*****@gmail.c om wrote on 3/29/06 5:37 PM:
and if you want the output as a string you should use
file_get_conten ts().


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($myFil e));
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_conten ts() 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
1883
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|| 03/01/04|item3||397||
3
2218
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 acheive this. Thanks in advance Ian $query="select * from Questions"; $rt=mysql_query($query); echo mysql_error();
0
2064
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 "Unrecognized tag prefix or device filter 'asp'" on the third line shown below... <head runat="server">
4
8011
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
1831
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 code SHOULD do: - read new (=updated) licensetext from file $license_path then - read and modify recursively all files from $current_dir, replacing old
1
3132
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 information written: peri|jones||||Submit Whereas the desired input should be as follows WITHOUT the submit button been printed and on a NEW LINE:
0
1263
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 filed name too at the top of each column. So, i m giving my code below and tell me where should i change and what code should written do access the field name too. <?php include("config.php"); include("connect.php"); $sql = "SELECT * FROM...
4
2770
by: nickyspace | last post by:
HI all I have a little issue with this php code. Below is the code CODE: PHP 1.<?
1
2936
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 exhausted (tried to allocate 3714000 bytes) in /opt/lampp/htdocs/tutorials/php-mysql-tutorial/admin/image-gallery/library/functions.php on line 104 Platform: Ubuntu 8.04 LST (where i make my programs, and test them before i upload them), Using XAMPP for...
0
9621
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8937
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7463
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6717
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.