Re: [PHP] fread problem
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 the amount of memory in 256M. The limitation is what you specify in your fread's second argument. If I understand the problem you are incrementally reading a file that is parsed for matching begin and ending elements, so if you have a document like: anode // 2048 characters of data /anode And you do a: $line = fread($fp, 2048); You wont get the closing element within the fread. Curt. -- cat .signature: No such file or directory -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fread problem
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://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fread problem
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 ($handle); echo $contents; [snip] You need to eval your code (not exec): eval($contents); Note that $contents need to be valid PHP for eval(). It must not start with ?php since eval assumes it is code anyway. Some examples: A) HTML with PHP interspersed bSome HTML/bbr /?php echo date('Y'); ?Blah you should eval(?$contents?php); B) Plain PHP echo date('Y'); you should eval($contents); C) Incomplete PHP (missing semicolon) call_this_function(blah) you should eval($contents;); If the PHP code returns some value, this will be the return of eval: $contents=return time();; $t = eval($contents); You get the idea. -- O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[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 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 = fopen ($filename, r); $contents = fread ($handle, filesize ($filename)); fclose ($handle); echo $contents; Here is test.php ?PHP echo Hello World; ? END test.php When I run this, I get a blank page with my php code as my HTML source code. Not good. Finally, if you respond to this, please copy me directly as I get the mailing list as a digest. Thx, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] fread problem
you'll have to exec() the code $filename = test.php; $handle = fopen ($filename, r); $contents = fread ($handle, filesize ($filename)); fclose ($handle); exec($contents); see if that works Martin -Original Message- 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 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 = fopen ($filename, r); $contents = fread ($handle, filesize ($filename)); fclose ($handle); echo $contents; Here is test.php ?PHP echo Hello World; ? END test.php When I run this, I get a blank page with my php code as my HTML source code. Not good. Finally, if you respond to this, please copy me directly as I get the mailing list as a digest. Thx, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] fread problem
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 = fopen ($filename, r); $contents = fread ($handle, filesize ($filename)); fclose ($handle); echo $contents; Here is test.php ?PHP echo Hello World; ? END test.php When I run this, I get a blank page with my php code as my HTML source code. Not good. If you want the result of your PHP file, then open it through HTTP. $filename = http://www.yourdomain.com/test.php;; and everything else remains the same. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php