I was just wondering why fread() seems to use so much memory when
reading in a file. My php.ini has a script memory limit of 32MB, yet PHP
hits its memory limit on a 19MB mbox file that I'm reading in. How is it
possible that this function can use 150% of a files' size in memory?!
Thanks,
Ash
htt
you have magic_quotes_runtime turned on LOCALLY. Use phpinfo() to see.
NOmagic_quotes_runtime Off
you actually managed to put the backslashes into your text file.
NO
.
.
.
.
,/()%...@!',''); //fix special chars in
name
$_POST[$fname.'_fname'] = strtr($_POST[$fname.'
PHP does *not* do the addslashes on $_POST when you cram something into it in
your PHP code.
It does it during the process of auto-filling up $_POST.
So either:
A) you have magic_quotes_runtime turned on LOCALLY. Use phpinfo() to see.
B) you actually managed to put the backslashes into yo
Hah! Forgot to add the link:
1. http://php.net/ini_set
How would you guys have ever figured out that was the page on PHP's
website you need to visit in order to view information about the
ini_set() function?!
;)
// Todd
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe,
> -Original Message-
> From: MikeP [mailto:mpel...@princeton.edu]
> Sent: Thursday, December 18, 2008 7:33 AM
> To: php-general@lists.php.net
> Subject: Re: [PHP] fread question
>
> Still having problems:
> magic_quotes_runtime is off
> BUT
> magic_quotes_
Still having problems:
magic_quotes_runtime is off
BUT
magic_quotes_gpc is on
I cant change them myself so I tried
stripslashes
That doesnt work though:
$_POST[$fname] = fread($fileHandle, $_POST[$fname.'_size']);
$test=$_POST[$fname];
$test3=stripslashes($test);
$test3 and $test are the
But this one is ON
magic_quotes_gpc
"Robert Cummings" wrote in message
news:1229567238.8302.35.ca...@localhost...
> On Wed, 2008-12-17 at 19:54 -0500, MikeP wrote:
>> Hello,
>> I have been trying to use fread to open a file, but it always escapes
>> special characters.
>> How do I open afile wit
>From my phpinfo:
magic_quotes_runtime Off
"Robert Cummings" wrote in message
news:1229567238.8302.35.ca...@localhost...
> On Wed, 2008-12-17 at 19:54 -0500, MikeP wrote:
>> Hello,
>> I have been trying to use fread to open a file, but it always escapes
>> special characters.
>> How do I o
On Wed, 2008-12-17 at 19:54 -0500, MikeP wrote:
> Hello,
> I have been trying to use fread to open a file, but it always escapes
> special characters.
> How do I open afile without it modifying my original file:
>
> $_POST[$fname] = fread($fileHandle, $_POST[$fname.'_size']);
> I use this and ge
Hello,
I have been trying to use fread to open a file, but it always escapes
special characters.
How do I open afile without it modifying my original file:
$_POST[$fname] = fread($fileHandle, $_POST[$fname.'_size']);
I use this and get slashes everywhere.This kills my REGex that gets coded
next
Greetings, Jochem Maas.
In reply to Your message dated Thursday, November 20, 2008, 22:11:09,
> good stuff from Stut & Craige ... I just wondered, Im pretty sure that the
> usleep(1000) is completely superfluous. fread() will read to the buffer length
> or EOF regardless of how slow the stream tri
Stut schreef:
> On 20 Nov 2008, at 01:29, Rene Fournier wrote:
>> I'm trying to understand something about fread(). I'm using fread() on
>> an incoming socket stream that will send, for example, 26630 characters:
>>
>> while ( ($buf=fread($read[$i], 8192)) != '' ) {
>> $sock_data .= $buf;
>>
On 20 Nov 2008, at 01:29, Rene Fournier wrote:
I'm trying to understand something about fread(). I'm using fread()
on an incoming socket stream that will send, for example, 26630
characters:
while ( ($buf=fread($read[$i], 8192)) != '' ) {
$sock_data .= $buf;
usleep(1000);
Rene Fournier wrote:
So my question is, why does fread wait if there is nothing more to
read? Shouldn't it return immediately? (That's what I want.) And as
for the delay, it's there so that if the incoming data is a little
slow, it has time to catch up with fread. Thanks.
...Rene
I do belie
I'm trying to understand something about fread(). I'm using fread() on
an incoming socket stream that will send, for example, 26630 characters:
while ( ($buf=fread($read[$i], 8192)) != '' ) {
$sock_data .= $buf;
usleep(1000);
echo ".";
}
echo ",";
As soon as th
On Mon, Jan 02, 2006 at 09:35:21PM +0100, Mario de Frutos Dieguez wrote:
> Hi!
>
> I have a problem using fread with a XML document. When i read some nodes
> with a great amount of text it cuts in the same place of the text. There
> are any limitation of text or something? I have in the php.ini th
Hi!
I have a problem using fread with a XML document. When i read some nodes
with a great amount of text it cuts in the same place of the text. There
are any limitation of text or something? I have in the php.ini the amount
of memory in 256M.
Thanks in advance
--
PHP General Mailing List (http:
Sorry for the bump, but please anyone? :P
Quoting The Gimper <[EMAIL PROTECTED]>:
> On the php.net you can read the following about fread:
>
> "fread() reads up to length bytes from the file pointer referenced by
> handle.
> Reading stops when length bytes have been read, EOF (end of file) is
>
On the php.net you can read the following about fread:
"fread() reads up to length bytes from the file pointer referenced by handle.
Reading stops when length bytes have been read, EOF (end of file) is reached,
or (for network streams) when a packet becomes available, whichever comes
first."
I
I'm trying to use a PHP script to test the throughput from a few
different web servers on a test network at work. I'm doing an fopen
with the URL, and then a read loop like this:
while (!feof($handle)) {
fread($handle, 8192);
}
I'm ignoring the data returned by fread, since I'm just int
Russell P Jones wrote:
> Is there any way to use fread() or a similar function to read a section of
> a document NOT starting at the beginning...
>
> for example, I can read the first 1000 bytes of a document with
>
> fread($doc, 1000);
>
> Is there any way to read the second 1000 bytes?
>
> perhap
( http://www.google.com );
Archives::getUri( http://marc.theaimsgroup.com/?l=php-general );
-Original Message-
From: Russell P Jones [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 08, 2004 12:20 PM
To: [EMAIL PROTECTED]
Subject: [PHP] fread()
Is there any way to use fread() or a similar functio
Is there any way to use fread() or a similar function to read a section of
a document NOT starting at the beginning...
for example, I can read the first 1000 bytes of a document with
fread($doc, 1000);
Is there any way to read the second 1000 bytes?
perhaps, fread($doc, 1000, 2000); who knows..
Hi,
Using a a flat text file based calendar script.
Started getting this error after upgrading PHP:
Warning: fread(): Length parameter must be greater than 0
Function it is occurring in is:
function read_str($fp)
{
$strlen = $this->bin2dec(fread($fp,4),4);
return fread($fp, $strlen);
I'm running PHP 4.3.3 compiled with --with-openssl against Red Hat 8.0's
latest OpenSSL libraries (patched versions of 0.9.6) and am having some
strange issues using fopen(), fread() and friends. Here's my code:
function echo_test() {
$opts = array(
'ssl' => array(
'
I have an open socket that I am reading from. The code looks like the
following:
$contentLength = 0 + $this->response['headers']['content-length'];
do{
$status = socket_get_status($this->socket);
if( $status['eof'] == 1 ) {
if( $this->clientOptions['debug'] & DBGSOCK ) echo("DBG
Just wanted to let everyone else know so they don't waste days trying to
figure it out.
When using fread() on just about anything except for a file, it only
reads one packet at a time.
This means you must fread within a loop to read the bytes you need.
You can no longer pass "$length bytes to be r
On Thursday 06 March 2003 11:41, John Taylor-Johnston wrote:
> I need to upoload a local text file into memory using:
>
>
> The script below will only work if I am using my localhost.
>
> Any ideas?
What happens when you're NOT using localhost? And as this is an upload
problem, try searching the
I need to upoload a local text file into memory using:
The script below will only work if I am using my localhost.
Any ideas?
John
\n";
if (!$filename)
{
echo "!\$filename \n";
}else{
#$filename = "/usr/local/something.txt";
#echo "\$filename $filename\n";
$handle = fopen ($filename, "r");
At 05:46 03.03.2003, Paul Cohen said:
[snip]
>Here is the code in my file and was taken directly from the manual:
>
>$filename = "test.php";
>$handle = fopen ($filename, "r");
>$contents = fread ($handle, filesize ($filename));
>fclose ($handl
> I am trying to read a php file to a varible and then print that
variable.
> Unfortunately, my php file is not being parsed by the fread function
and I
> can't figure out why.
>
> Here is the code in my file and was taken directly from the manual:
>
> $filename = "test.php";
> $handle =
From: Paul Cohen [mailto:[EMAIL PROTECTED]
> Sent: Monday, March 03, 2003 3:46 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] fread problem
>
>
> Hello all,
>
> I am trying to read a php file to a varible and then print
> that variable.
> Unfortunately, my php file is not b
Hello all,
I am trying to read a php file to a varible and then print that variable.
Unfortunately, my php file is not being parsed by the fread function and I
can't figure out why.
Here is the code in my file and was taken directly from the manual:
$filename = "test.php";
$handle = fope
I'm trying to download various amount of information from handles opened by fsockopen.
fgets works but takes forever on very large files because it breaks on every line.
fread seems like it would work better but when I use a buffer of 1024 or 4096, it's
actually far SLOWER on small files.
Wha
;);
readfile($file);
- Original Message -
From: "Sora B. Harbater" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, November 04, 2002 12:44 AM
Subject: [PHP] fread() fails with large files
> Hi. I am using Linux/Apache with PHP 4.1.2. I have been experi
Hi. I am using Linux/Apache with PHP 4.1.2. I have been experiencing this
problem since upgrading from an earlier version of PHP 4.
My script forces a download of a PDF file after looking up some info in a
database. The code looks like this:
$file="/path/to/file";
$fp = fopen($file, "r");
$
Would not be closing the conection in the perl script enough?
Martin Adler wrote:
Hi,
this php-script should read from a server (that i've written in perl) until
it receives the EOF signal.
My server sends the EOF-signal by
print $client "\n\004"; # \004 = EOF
to my script but fread would
Hi,
this php-script should read from a server (that i've written in perl) until
it receives the EOF signal.
My server sends the EOF-signal by
print $client "\n\004"; # \004 = EOF
to my script but fread wouldn't stop reading
and i don't have any ideas why.
Is php using an other sign for EOF?
Hi!
Why fread() function do not read first two lines in a file?
I have a chrates.php file :
Title here!
PS.rates.php is:
'6.5596',
'ADP' => '183.180',
'AED' => '3.6725',
'AFA' => '4750.00',
'ALL' => '143.840',
'ANG' => '1.7800',
'AON' => '5.8956
res a session variable.
Zac
- Original Message -
From: "John Holmes" <[EMAIL PROTECTED]>
To: "'Zac Hillier'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, May 27, 2002 7:12 PM
Subject: RE: [PHP] fread and session vars
> Hi.
>
&g
Hi.
> Code:
>
> generate page script:
>
> $pge = create-page.php
> $pd = $HTTP_GET_VARS['pd'];
>
> # Set the files
> $crtPge = "/". $pge ."?pd=". $pd; # the url of the dynamic page to
write
> the
> output page
> $targetfilename = $SITE_ DOCUMENT_ROOT . $outPge; # the output page
>
> # delete
p.html') . " for writing.
Static page update aborted!");
exit();
}
#write to temp file
fwrite($tempfile, $htmldata);
# close the temp file
fclose($tempfile);
etc...
===
create-page.php:
To: "'Zac Hillier'&qu
Post some code. I don't understand completely what you're trying to do
or how you're trying to do it.
---John Holmes...
> -Original Message-
> From: Zac Hillier [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 27, 2002 9:20 AM
> To: [EMAIL PROTECTED]
> Su
Hi all,
I'm using the fread function to read one of my php scripts and then produce a static
page, within this script I'm using session variables.
If I browse to the script normally then all appears to work correctly, however when I
use the fread function the session variables are not being tr
Hello !
I've some tourble w/ the following piece of code. The file to read
doesn't contain zeros at the beginning, but the output is
a= 0 b=0
is there a problem w/ fread ? (php 4.0.6, RedHat 7.2)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED
Hi,
I am using fsockopen and fread to get the contents of a file on
a server. Everything seems to work fine, except for one url. Opening
http://ad-adex3.flycast.com/server/img/3327812_VBWeb/11196014_Restofsite
/999
Works fine, however,
http://www.burstnet.com/cgi-bin/ads/ad8747a.cgi?uniq=9
Hi,
I have a GSM modem connected to /dev/ttyS0 and would like to use php
to communicate with the modem. Writing works perfectly like this:
$fp=fopen("/dev/ttyS0","r+");
fwrite($fp,"AT+CMGL\r");
but reading is a little problem because if the modem for example answers
to the "AT+CMGL" message I s
I'm attempting to read a file from a remote server and save it to a
variable. The code below works fine if the remote server is unix based,
but fails with the server I actually need to retrieve data from (NT4 SP4,
beyond my control). When trying to fread from the NT server,
$invoice_contents en
> if( !($fd = @fopen($ftp_url, "r")) ){
> $error = true;
> $error_msg = "Unable to connect to server.";
> }
> else {
> $file_contents = fread($fd, 10);
> fclose($fd);
> }
>
> if( empty($file_contents) ){
> $error = true;
> $error_msg = "Did not read file.";
> }
>
>
> The problem is
I'm having some trouble reading a text file from a remote server into a
string. The code is as follows:
if( !($fd = @fopen($ftp_url, "r")) ){
$error = true;
$error_msg = "Unable to connect to server.";
}
else {
$file_contents = fread($fd, 10);
fclose($fd);
}
if( empty($file_content
David - very cool, thanks much for your help!
if any other newbies run into the same problem:
echo "stuff"; //prints "stuff"
echo $string; //prints contents of string, does NOT parse.
include(filename); //whenever encountered, prints contents of file
//parses only if PH
On Tue, 20 Feb 2001 11:37, Jaxon wrote:
> Same problem, found it's coming from somewhere else :(
> It looks as if fread or fopen is preventing PHP from from parsing ...
>
> index.php:
>
> $file="test.inc";
> $fd = fopen ($file, "r");
> $string = fread ($fd, filesize ($file));
> fclose ($fd);
> ec
Same problem, found it's coming from somewhere else :(
It looks as if fread or fopen is preventing PHP from from parsing ...
index.php:
test.inc:
index.html show a blank html page, with the contents of test.inc visible via
view source...grr. how can I get it to actually parse the PHP?
On Fri, Feb 09, 2001 at 09:02:04AM -0600, Tyler Longren wrote:
> Could you perform fread() on a remote file?
Yes I could, and so can you, so why not try it?
An example:
$handle = fopen("http://www.php.net/manual/en/function.fread.php", "r");
while($line = fread($handle, 255)) {
echo "$line";
Hello everybody,
Could you perform fread() on a remote file? Example:
$file = fopen("http://www.myurl.com/test.html", "rb");
$data = fread($file, filesize('http://www.myurl.com/test.html'));
???
Thanks!
Tyler Longren
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [
55 matches
Mail list logo