php-general Digest 20 Jul 2009 13:50:30 -0000 Issue 6240
Topics (messages 295599 through 295606):
Re: file_set_contents() do several times?
295599 by: Jim Lucas
295600 by: David Otton
295602 by: Martin Zvarík
295603 by: David Otton
Re: why does PHP parse "*.html" files in one subdir/ but not in another?
295601 by: Stuart
AS-EL Yeni Ürün Bilgilendirmesi
295604 by: AS-EL Yapý Market E-Bülten Sistemi
Re: Dual PHP installation and session sharing
295605 by: Bruno Fajardo
Re: PHP and FoxPro
295606 by: Floyd Resler
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Martin Zvarík wrote:
<?php
$i = 0;
do {
$i++;
$r = file_put_contents('file.txt', 'content');
} while($r === false && $i < 3);
if ($r === false) die('error');
?>
Makes sense? or is it enough to do it just once?
You call file_put_contents() once.
it writes an entire file when called.
use fopen/fwrite/fclose to do it line by line.
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
--- End Message ---
--- Begin Message ---
2009/7/20 Martin Zvarík <[email protected]>:
>
> <?php
> $i = 0;
> do {
> $i++;
> $r = file_put_contents('file.txt', 'content');
> } while($r === false && $i < 3);
>
> if ($r === false) die('error');
>
> ?>
>
> Makes sense? or is it enough to do it just once?
Assuming 'content' changes, and this is the cut-down example...
$r = file_put_contents('file.txt', 'content', FILE_APPEND);
There's a small overhead in opening/closing the file three times
instead of one, but I doubt that's going to be an issue for you.
--- End Message ---
--- Begin Message ---
David Otton napsal(a):
> 2009/7/20 Martin Zvarík <[email protected]>:
>> <?php
>> $i = 0;
>> do {
>> $i++;
>> $r = file_put_contents('file.txt', 'content');
>> } while($r === false && $i < 3);
>>
>> if ($r === false) die('error');
>>
>> ?>
>>
>> Makes sense? or is it enough to do it just once?
>
> Assuming 'content' changes, and this is the cut-down example...
>
> $r = file_put_contents('file.txt', 'content', FILE_APPEND);
>
> There's a small overhead in opening/closing the file three times
> instead of one, but I doubt that's going to be an issue for you.
>
I am not appending anything, just ensuring that it will be written (and
giving it max. 3 tryes).
=== Martin Scotta replied:
In my experience file_put_contents never fails, except about file
permissions, but this is not the case.
---
Thanks for your replies.
Martin
--- End Message ---
--- Begin Message ---
2009/7/20 Martin Zvarík <[email protected]>:
>> 2009/7/20 Martin Zvarík <[email protected]>:
>>> <?php
>>> $i = 0;
>>> do {
>>> $i++;
>>> $r = file_put_contents('file.txt', 'content');
>>> } while($r === false && $i < 3);
>>>
>>> if ($r === false) die('error');
>>>
>>> ?>
>>>
> I am not appending anything, just ensuring that it will be written (and
> giving it max. 3 tryes).
Ok, don't do that. If it didn't work the first time, it won't work
0.001 seconds later, either. Chances are it will either be a
permissions error, or out-of-disc-space.
--- End Message ---
--- Begin Message ---
2009/7/19 Paul M Foster <[email protected]>:
> On Sun, Jul 19, 2009 at 07:18:34PM +0100, Stuart wrote:
>
>> 2009/7/19 Paul M Foster <[email protected]>:
>> > On Sun, Jul 19, 2009 at 09:30:33AM +0530, kranthi wrote:
>> >
>> >>
>> >> > You do realize that PHP does not parse HTML files, right? The web server
>> >> > does that. In fact, the web server also parses PHP files, using a
>> >> > different library.
>> >>
>> >> Kindly elaborate If you are saying that PHP cant parse files with
>> >> extension .html
>> >> http://us2.php.net/manual/en/security.hiding.php.
>> >
>> > That's exactly what I'm saying. Apache or IIS (or whatever) discern the
>> > contents of a file and determine how to parse it. As far as I know,
>> > Apache, even with a PHP file, parses the HTML in the file and hands PHP
>> > off to a PHP module to decode. The PHP engine itself does not parse the
>> > HTML which is interspersed in and amongst your PHP code. The web server
>> > does that. Unless some php internals person says otherwise, that's the
>> > story. At best, the PHP engine would simply echo non-PHP text to the
>> > browser, which is not parsing it.
>>
>> Actually that's not accurate. The web server does nothing with a file
>> before it passes it to the PHP engine. PHP gets the entire file, it
>> simply echo's anything not inside PHP tags.
>
> Then I stand corrected. But again, this means that PHP doesn't actually
> *parse* the HTML it echoes.
Technically it parses the the entire file looking for PHP tags, but
that's being overly picky.
-Stuart
--
http://stut.net/
--- End Message ---
--- Begin Message ---
AS-EL E-Bülten Sistemi
SORUN BİNANIZA KİMLİK KAZANDIRMAKSA..,
ÇÖZÜM AS-EL MİMARİ SİSTEMLER’de
İŞTE YENİ NESİL CEPHE KAPLAMA MALZEMESİ
AS-EL Yapı Endüstri Market A.Ş.
5709 sk. No 39 Karabağlar İZMİR
(0 232) 264 66 66
www.as-el.com.tr
Mail listesinden çıkmak için lütfen [email protected]
adresine boş bir mail atınız.
--- End Message ---
--- Begin Message ---
Hi, Zareef.
I have not tried storing session in a database, and I think it's not
an option in my case, since I'm working on a legacy software that uses
distributed databases across several servers.
Actually, I guess it would be easier to setup a new webserver, running
PHP 5 only, and discontinue the current one. But if there's a chance
to share session in the actual environment, I would certainly prefer
that.
Thanks for the reply!
2009/7/19 Zareef Ahmed <[email protected]>
>
>
> On Sat, Jul 18, 2009 at 1:34 AM, Bruno Fajardo <[email protected]> wrote:
>>
>> Hi all,
>>
>> I'm using Apache/2.2.3 (Linux/SUSE), running PHP 4.4.7 in CGI mode, in a
>> dual installation with PHP 5.1.2 running as an Apache module.
>> Scripts with .php5 extension are executed by PHP 5, and those with .php are
>> executed by PHP 4, and everything runs as expected.
>> My question is: is it possible to share session data between .php and .php5
>> scripts in this environment? All my tests failed.
>
> have you tried using database as session storage and setting session id
> manually in your application.
>>
>>
>> Thanks in advance!
>
>
>
> --
> Zareef Ahmed :: A PHP Developer in India ( Delhi )
> Homepage :: http://www.zareef.net
--- End Message ---
--- Begin Message ---
Paul,
Believe me I would like nothing more that to get rid of FoxPro and
convert it to MySQL. Sadly, that's not possible right now. I'll check
into dBase.
Thanks!
Floyd
On Jul 19, 2009, at 4:53 PM, Paul M Foster wrote:
On Sun, Jul 19, 2009 at 09:00:49AM -0400, Floyd Resler wrote:
We currently use the Easysoft ODBC Bridge to connect to a remote
FoxPro database. The problem is that the bridge, after a while,
starts consuming a ton of system resources and we have to reboot the
machine. Afterwards, it can take upwards to two hours before
everything is running quickly again. We need another solution. Does
anyone know of a any other way to connect to a remote FoxPro database
(or any ODBC source that isn't a database server)?
No way to convert the FoxPro to PostgreSQL or MySQL? FoxPro is ancient
and decrepit (I used to code in FoxPro).
There is a dBase module for PHP. I don't know if it handles generic
xBase files. I don't know much about the module, but you could check
it
out.
Paul
--
Paul M. Foster
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---