php-general Digest 15 Dec 2006 05:48:45 -0000 Issue 4515

Topics (messages 245830 through 245850):

Re: learning classes not sure how to do this correctly
        245830 by: Jochem Maas
        245849 by: Macha

Re: php redirection..
        245831 by: bruce
        245833 by: Brad Fuller

Re: Havn't been on the list in a while
        245832 by: Jim Lucas

date() and timezone
        245834 by: Fernando M. M.
        245835 by: Jochem Maas
        245836 by: Stut
        245837 by: Fernando M. M.
        245838 by: Jochem Maas
        245839 by: Jonesy
        245841 by: Jochem Maas

Having problem sending XML over HTTP
        245840 by: Nauman Akbar
        245842 by: Brad Fuller

date formatting - no question here just a tip ...
        245843 by: Jochem Maas

Re: How php works?
        245844 by: Richard Lynch

google video like site
        245845 by: siavash1979.telus.net
        245846 by: Jochem Maas
        245848 by: Robert Cummings

PDO statement/resultset
        245847 by: David Duong

RegExp
        245850 by: WeberSites LTD

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 ---
[EMAIL PROTECTED] wrote:
> just starting to get used to classes, trying to figure out what i am
> doing wrong, i know its going to be something stupid on my part,
> probably really shouldn't be using a if statement or something heh
> 
> just doing a basic email verification to make sure its looks like email
> addy
> 
> so i take the post to a var
> 
> PHP Code:
> $email_address = $_POST['email_address'];
> 
> 
> run it through this function in my class
> 
> PHP Code:
> function check_email($address){
>         if (ereg('[EMAIL PROTECTED]',
> $address))

please consider using the preg_*() functions instead of the posix based
regexp funcs; read here to get a feel of why the preg_*() funcs are 'better':

        http://php.net/manual/en/ref.regex.php

also you could shorten the function a little like so;

function check_email($address) {
        return (boolean) ereg('[EMAIL PROTECTED]',$address);
}

>             return true;
>         else
>             return false;
>     }
> 
> 
> and then if true i want it to continue on with the script or error out
> and quit back to the other page and display the error. so i have tried
> something like this and stuff similar but get a error
> Fatal error: Call to a member function on a non-object in

$keclass is not an object. you need to do something like this
before you use $keclass (where 'YourClass' is the name of your class):

$keclass = new YourClass;

> 
> PHP Code:
> if (!$keclass->check_email($email_address)) {
>     $keclass->seterr(555);
>     include('test.php');
>     exit();
> }
> 
> $keclass->seterr(000);
> include('test.php');
> exit();
> 
> 
> the seterr is just a simple thing that takes the number and puts in a
> session var for latter display...
> 

--- End Message ---
--- Begin Message --- I'm not sure if it matters or not, but this is happening on the page that you are sent to from hitting the submit button from the other page...test.php is a form that sends you to test2.php after hitting the submit button and its test2.php page that is having this issue with the $keclass.

with that on test2.php if i use var_dump($keclass) i get *'Notice*: Undefined variable: keclass' and *'Fatal error*: Call to a member function on a non-object' on any $keclass -> function call witch makes since, but if i try to declare the class in test2.php with var_dump($keclass) i get object(keclass)(0) but i get *Fatal error*: Cannot redeclare class keclass. so i guess that information changes the question down to why is it saying that i am redeclaring $keclass when it hasnt been declared in that page before? is it something do to with test.php when u hit submit and being redirected to test2.php?

If this dosnt really make any sense let me know..i have been told serveal times in the past i dont really explain my self well hehe

Richard Lynch wrote:
var_dump($keclass);

It's not an object...


On Thu, December 14, 2006 9:16 am, [EMAIL PROTECTED] wrote:
just starting to get used to classes, trying to figure out what i am
doing wrong, i know its going to be something stupid on my part,
probably really shouldn't be using a if statement or something heh

just doing a basic email verification to make sure its looks like
email
addy

so i take the post to a var

PHP Code:
$email_address = $_POST['email_address'];


run it through this function in my class

PHP Code:
function check_email($address){
        if
(ereg('[EMAIL PROTECTED]',
$address))
            return true;
        else
            return false;
    }


and then if true i want it to continue on with the script or error out
and quit back to the other page and display the error. so i have tried
something like this and stuff similar but get a error
Fatal error: Call to a member function on a non-object in

PHP Code:
if (!$keclass->check_email($email_address)) {
    $keclass->seterr(555);
    include('test.php');
    exit();
}

$keclass->seterr(000);
include('test.php');
exit();


the seterr is just a simple thing that takes the number and puts in a
session var for latter display...

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--- End Message ---
--- Begin Message ---
all these are solid posts...

however, the original posting, was not to do a redirect on the page being
presented.

the original post, was to display some content rolling down the page, wait
some time, and 'then' redirect the user to another page. i wanted to be able
to accomplish this without having the user hitting some 'submit' button.

thanks!


-----Original Message-----
From: Brad Fuller [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 14, 2006 8:40 AM
To: 'PHP General List'
Subject: RE: [PHP] php redirection..



Better to do this on the client side with JS

<html>
<head>
<title>Redirect Test</title>
<script language="JavaScript">
function redirect() {
        location.href='http://www.google.com/';
}
</script>
</head>
<body onLoad="setTimeout('redirect()', 3000);">
<p>You will be redirected in 3 seconds...</p>
</body>
</html>


> -----Original Message-----
> From: Youri LACAN-BARTLEY [mailto:[EMAIL PROTECTED]
> Sent: Thursday, December 14, 2006 10:44 AM
> To: PHP General List
> Subject: Re: [PHP] php redirection..
>
> Budi Setiawan wrote:
> >> basically:
> >>
> >> cat.php
> >>  -echo " test content<br>"
> >>  -echo " more test content<br>"
> >>
> >> //redirect user
> >>  echo"
> >>   <script>
> >>     location.href='foo.php';
> >>   </script>
> >>  ";
> >>
> >
> >
> > Hi , im a new too..
> >
> > but you can try with this to delay your script running for some seconds
> :
> > echo " test content<br>"
> > echo " more test content<br>"
> >
> > // you can add :
> > sleep(2);
> > // this will cause your script delayed for 2 seconds
> >
> > //redirect user
> > echo"
> > <script>
> > location.href='foo.php';
> > </script>
> > ";
> >
>
> This would work providing you don't use output buffering, otherwise the
> user won't see any data whatsoever that has been sent prior to the
> sleep() call.
>
> >
> > // hhaha..
> > // im just trying to help...
> > //
> >
>
> --
> 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

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: bruce [mailto:[EMAIL PROTECTED]
> Sent: Thursday, December 14, 2006 12:08 PM
> To: 'Brad Fuller'; 'PHP General List'
> Subject: RE: [PHP] php redirection..
> 
> all these are solid posts...
> 
> however, the original posting, was not to do a redirect on the page being
> presented.
> 
> the original post, was to display some content rolling down the page, wait
> some time, and 'then' redirect the user to another page. i wanted to be
> able
> to accomplish this without having the user hitting some 'submit' button.


Uhhh... what do you think setTimeout() does?

Did you even look at the code, let alone test it?  


> thanks!
> 
> 
> -----Original Message-----
> From: Brad Fuller [mailto:[EMAIL PROTECTED]
> Sent: Thursday, December 14, 2006 8:40 AM
> To: 'PHP General List'
> Subject: RE: [PHP] php redirection..
> 
> 
> 
> Better to do this on the client side with JS
> 
> <html>
> <head>
> <title>Redirect Test</title>
> <script language="JavaScript">
> function redirect() {
>       location.href='http://www.google.com/';
> }
> </script>
> </head>
> <body onLoad="setTimeout('redirect()', 3000);">
> <p>You will be redirected in 3 seconds...</p>
> </body>
> </html>
> 
> 
> > -----Original Message-----
> > From: Youri LACAN-BARTLEY [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, December 14, 2006 10:44 AM
> > To: PHP General List
> > Subject: Re: [PHP] php redirection..
> >
> > Budi Setiawan wrote:
> > >> basically:
> > >>
> > >> cat.php
> > >>  -echo " test content<br>"
> > >>  -echo " more test content<br>"
> > >>
> > >> //redirect user
> > >>  echo"
> > >>   <script>
> > >>     location.href='foo.php';
> > >>   </script>
> > >>  ";
> > >>
> > >
> > >
> > > Hi , im a new too..
> > >
> > > but you can try with this to delay your script running for some
> seconds
> > :
> > > echo " test content<br>"
> > > echo " more test content<br>"
> > >
> > > // you can add :
> > > sleep(2);
> > > // this will cause your script delayed for 2 seconds
> > >
> > > //redirect user
> > > echo"
> > > <script>
> > > location.href='foo.php';
> > > </script>
> > > ";
> > >
> >
> > This would work providing you don't use output buffering, otherwise the
> > user won't see any data whatsoever that has been sent prior to the
> > sleep() call.
> >
> > >
> > > // hhaha..
> > > // im just trying to help...
> > > //
> > >
> >
> > --
> > 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
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

--- End Message ---
--- Begin Message ---
Chuck Anderson wrote:
Jim Lucas wrote:
Seems like this list has slowed down alot.

Anybody else notice this, or am I just missing something?

jl

If you're referring to what I think you are .... yes ..... I get almost nothing but timeouts when trying to do anything in this newsgroup.

nope, that isn't what I was referring to. I don't get the volume of mail from this list like I did 2 or 3 years ago.
--- End Message ---
--- Begin Message ---

Hello,

I have a lot of php scripts that uses date() for some important
operations. Yesterday those scripts were moved to another server which is on an
different timezone. I haven't predicted this so my scripts aren't working 
anymore. The
servers timezone is GMT -4 and mine is GMT -2. Is there a way to change the 
default
timezone for all scripts within a folder? And what about changing just one?

I
appreciate any help.

Thanks,

Fernando.


-- 

Blog: http://blog.forumdebian.com.br/fernando
Contato:
http://www.forumdebian.com.br/fernando/contato.php

--- End Message ---
--- Begin Message ---
Fernando M. M. wrote:
> 
> Hello,
> 
> I have a lot of php scripts that uses date() for some important
> operations. Yesterday those scripts were moved to another server which is on 
> an
> different timezone. I haven't predicted this so my scripts aren't working 
> anymore. The
> servers timezone is GMT -4 and mine is GMT -2. Is there a way to change the 
> default
> timezone for all scripts within a folder? And what about changing just one?

it depends on what version of php.

php5: http://php.net/manual/en/function.date-default-timezone-set.php
      http://php.net/manual/en/function.date-timezone-set.php

php4: er ... I believe your stuck with settings the TZ environment var OR doing 
some gnarly
hack in userland to account for the difference in timezones. (try this page and 
search for 'TZ':
http://php.net/manual/en/ref.datetime.php)

> 
> I
> appreciate any help.
> 
> Thanks,
> 
> Fernando.
> 
> 

--- End Message ---
--- Begin Message ---
Fernando M. M. wrote:
I have a lot of php scripts that uses date() for some important
operations. Yesterday those scripts were moved to another server which is on an
different timezone. I haven't predicted this so my scripts aren't working 
anymore. The
servers timezone is GMT -4 and mine is GMT -2. Is there a way to change the 
default
timezone for all scripts within a folder? And what about changing just one?

http://php.net/date_default_timezone_set

-Stut

--- End Message ---
--- Begin Message ---

I´m using php5 here.

But like i said i have lots of scripts inside this
folder, is there a way to set something on .htaccess to change the timezone?




> Fernando M. M. wrote:
>>
>> Hello,
>>
>> I have a lot of php scripts that uses date() for some
important
>> operations. Yesterday those scripts were moved to another server
which is on an
>> different timezone. I haven't predicted this so my scripts
aren't working anymore. The
>> servers timezone is GMT -4 and mine is GMT -2.
Is there a way to change the default
>> timezone for all scripts within a
folder? And what about changing just one?
> 
> it depends on what
version of php.
> 
> php5:
http://php.net/manual/en/function.date-default-timezone-set.php
>      
http://php.net/manual/en/function.date-timezone-set.php
> 
> php4: er
... I believe your stuck with settings the TZ environment var OR doing some
>
gnarly
> hack in userland to account for the difference in timezones. (try this
page and search
> for 'TZ':
>
http://php.net/manual/en/ref.datetime.php)
> 
>>
>> I
>> appreciate any help.
>>
>> Thanks,
>>
>> Fernando.
>>
>>
> 
> 


-- 

Blog: http://blog.forumdebian.com.br/fernando
Contato:
http://www.forumdebian.com.br/fernando/contato.php

--- End Message ---
--- Begin Message ---
Fernando M. M. wrote:
> 
> I´m using php5 here.
> 
> But like i said i have lots of scripts inside this
> folder, is there a way to set something on .htaccess to change the timezone?
> 

yes. I suggest you actually following the given links and read what's there -
that's what I did to answer your question and in doing so also found the answer
your above question.

> 
> 
> 
>> Fernando M. M. wrote:
>>> Hello,
>>>
>>> I have a lot of php scripts that uses date() for some
> important
>>> operations. Yesterday those scripts were moved to another server
> which is on an
>>> different timezone. I haven't predicted this so my scripts
> aren't working anymore. The
>>> servers timezone is GMT -4 and mine is GMT -2.
> Is there a way to change the default
>>> timezone for all scripts within a
> folder? And what about changing just one?
>> it depends on what
> version of php.
>> php5:
> http://php.net/manual/en/function.date-default-timezone-set.php
>>      
> http://php.net/manual/en/function.date-timezone-set.php
>> php4: er
> ... I believe your stuck with settings the TZ environment var OR doing some
> gnarly
>> hack in userland to account for the difference in timezones. (try this
> page and search
>> for 'TZ':
>>
> http://php.net/manual/en/ref.datetime.php)
>>> I
>>> appreciate any help.
>>>
>>> Thanks,
>>>
>>> Fernando.
>>>
>>>
>>
> 
> 

--- End Message ---
--- Begin Message ---
On Thu, 14 Dec 2006 16:56:55 -0200 (BRST), Fernando M. M. wrote:
> ------=_20061214165655_35409
> Content-Type: text/plain; charset="iso-8859-1"
> Content-Transfer-Encoding: 8bit
>
> I´m using php5 here.
>
> But like i said i have lots of scripts inside this
> folder, is there a way to set something on .htaccess to change the timezone?

Please don't top post.

RTFM you were pointed to: "Instead of using this function to set the 
default timezone in your script, you can also use the INI setting 
date.timezone to set the default timezone.

What you were pointed to before + >
 http://us3.php.net/manual/de/ini.php#ini.list

Jonesy
-- 
  Marvin L Jones    | jonz          | W3DHJ  | linux
   38.24N  104.55W  |  @ config.com | Jonesy |  OS/2
    *** Killfiling google posts: <http//jonz.net/ng.htm>

--- End Message ---
--- Begin Message ---
Jonesy wrote:
> On Thu, 14 Dec 2006 16:56:55 -0200 (BRST), Fernando M. M. wrote:
>> ------=_20061214165655_35409
>> Content-Type: text/plain; charset="iso-8859-1"
>> Content-Transfer-Encoding: 8bit
>>
>> I´m using php5 here.
>>
>> But like i said i have lots of scripts inside this
>> folder, is there a way to set something on .htaccess to change the timezone?
> 

why? ;-)

> Please don't top post.
> 
> RTFM you were pointed to: "Instead of using this function to set the 
> default timezone in your script, you can also use the INI setting 
> date.timezone to set the default timezone.
> 
> What you were pointed to before + >
>  http://us3.php.net/manual/de/ini.php#ini.list

ah, now you've gone and made it easy for him :-)

> 
> Jonesy

--- End Message ---
--- Begin Message ---
Hello!

 

I picked up an example from Curl section on php.net. I am able to access the
remote page fine with a custom header. Unfortunately, I am not able to
retrieve the XML I am sending at the remote end. I have tried both
$HTTP_RAW_POST_DATA and php://input but neither of them returns anything. I
am putting my code below just in case anyone can point out the problem in
there.

 

$xmlstr = <<<XML

<query>

            <username>fff-bbbb</username>

            <password>alphanumeric</password>

            <function>GetPackageVersion</function>

</query>

XML;

 

$header[] = "MIME-Version: 1.0 \r\n";

$header[] = "Content-type: multipart/mixed; boundary=----doc \r\n";

//$header[] = "Accept: text/xml \r\n";

$header[] = "Content-length: ".strlen($xmlstr)." \r\n";

$header[] = "Cache-Control: no-cache";

$header[] = "Connection: close \r\n\r\n";

$header[] = $xmlstr;

 

print("setting url<BR>");

$request = curl_init("http://mrcod.concisehosting.com/index.php";);

print("setting options<BR>");

curl_setopt($request, CURLOPT_RETURNTRANSFER, true);

curl_setopt($request, CURLOPT_TIMEOUT, 4);

curl_setopt($request, CURLOPT_HTTPHEADER, $header);

curl_setopt($request, CURLOPT_CUSTOMREQUEST, 'POST');

 

print("connecting...<BR>");

$response = curl_exec($request);

//curl_exec($request);

curl_close($request);

print($response);

 

I have checked the ini file. Memory reserved for POST is 8M. Moreover, I
even tried turning 'always_populate_http_raw_post_data' but it doesn't work.
Any one any ideas, I am in real need for help on this.

 

Regards

Nauman Akbar

Concise Solutions


--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Nauman Akbar [mailto:[EMAIL PROTECTED] On Behalf Of Nauman
> Akbar
> Sent: Thursday, December 14, 2006 3:32 PM
> To: [email protected]
> Subject: [PHP] Having problem sending XML over HTTP
> 
> Hello!
> 
> 
> 
> I picked up an example from Curl section on php.net. I am able to access
> the
> remote page fine with a custom header. Unfortunately, I am not able to
> retrieve the XML I am sending at the remote end. I have tried both
> $HTTP_RAW_POST_DATA and php://input but neither of them returns anything.
> I
> am putting my code below just in case anyone can point out the problem in
> there.
> 
> 
> 
> $xmlstr = <<<XML
> 
> <query>
> 
>             <username>fff-bbbb</username>
> 
>             <password>alphanumeric</password>
> 
>             <function>GetPackageVersion</function>
> 
> </query>
> 
> XML;
> 
> 
> 
> $header[] = "MIME-Version: 1.0 \r\n";
> 
> $header[] = "Content-type: multipart/mixed; boundary=----doc \r\n";
> 
> //$header[] = "Accept: text/xml \r\n";
> 
> $header[] = "Content-length: ".strlen($xmlstr)." \r\n";
> 
> $header[] = "Cache-Control: no-cache";
> 
> $header[] = "Connection: close \r\n\r\n";
> 
> $header[] = $xmlstr;
> 
> 
> 
> print("setting url<BR>");
> 
> $request = curl_init("http://mrcod.concisehosting.com/index.php";);
> 
> print("setting options<BR>");
> 
> curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
> 
> curl_setopt($request, CURLOPT_TIMEOUT, 4);
> 
> curl_setopt($request, CURLOPT_HTTPHEADER, $header);
> 
> curl_setopt($request, CURLOPT_CUSTOMREQUEST, 'POST');
> 
> 
> 
> print("connecting...<BR>");
> 
> $response = curl_exec($request);
> 
> //curl_exec($request);
> 
> curl_close($request);
> 
> print($response);
> 
> 
> 
> I have checked the ini file. Memory reserved for POST is 8M. Moreover, I
> even tried turning 'always_populate_http_raw_post_data' but it doesn't
> work.
> Any one any ideas, I am in real need for help on this.
> 
> 
> 
> Regards
> 
> Nauman Akbar
> 
> Concise Solutions


Try this:

--------------------------------
The code for the sending script:

<?php
$xmlstr =
"<query><username>fff-bbbb</username><password>alphanumeric</password><funct
ion>GetPackageVersion</function></query>";

$ch=curl_init(); 
curl_setopt($ch, CURLOPT_URL, "http://example.com/your-accepting-page.php";);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, "xmlstr=".urlencode($xmlstr)); 
curl_setopt($ch, CURLOPT_TIMEOUT, 120); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$buffer = curl_exec($ch); 
curl_close($ch);

print_r($buffer);
?>

----------------------------------
The code for the receiving script:

<?php

if(!empty($_POST)) {
        echo "You sent me some data... here is what I received:\n";
        print_r($_POST);
}

?>

Then open a browser and surf to the sending script.  It should print the
response from the receiving page.

Here is the output:

You sent me some data... here is what I received:
Array
(
    [xmlstr] =>
<query><username>fff-bbbb</username><password>alphanumeric</password><functi
on>GetPackageVersion</function></query>
)

I tested this and its working (at least on my server).

Sorry I don't have the time to tell you what is wrong with your code but
it's easier for me to just provide something that works.

I hope that helps you,

Brad

--- End Message ---
--- Begin Message ---
have you ever had the need to programmatically convert a date()
compatible date formatting string with one compatible for strftime()?

I had this problem recently when I had to l10n an existing app (and
support legacy data - which include date() formatting strings - at the
same time) ... I came up with this (it's not very exciting but it might save
someone the rather mindnumbing job of trying to correlate the date()
and strftime() formatting codes - also note that the correlation is not 100%,
in cases where I couldn't find a real/proper match I just did what I thought
was best - which sometimes meant leaving the replacement blank):

function getSTFDateFormat($fmt)
{
    static $dfMap = array(
        'd'     => '%d', // Day of the month, 2 digits with leading zeros       
01 to 31
        'D'     => '%a', // A textual representation of a day, three letters    
Mon through Sun
        'j'     => '%e', // Day of the month without leading zeros      1 to 31
        'l' => '%A', // A full textual representation of the day of the week    
Sunday through Saturday
        'N'     => '%u', // ISO-8601 numeric representation of the day of the 
week (added in PHP 5.1.0) 1 (for Monday)
through 7 (for Sunday)
        'S'     => '',   // English ordinal suffix for the day of the month, 2 
characters       st, nd, rd or th. Works well with j
        'w'     => '%w', // Numeric representation of the day of the week       
0 (for Sunday) through 6 (for Saturday)
        'z'     => '%j', // The day of the year (starting from 0)       0 
through 365
        'W'     => '%V', // ISO-8601 week number of year, weeks starting on 
Monday (added in PHP 4.1.0) Example: 42 (the
42nd week in the year)
        'F'     => '%B', // A full textual representation of a month, such as 
January or March  January through December
        'm'     => '%m', // Numeric representation of a month, with leading 
zeros       01 through 12
        'M'     => '%b', // A short textual representation of a month, three 
letters    Jan through Dec
        'n'     => '%m', // Numeric representation of a month, without leading 
zeros    1 through 12
        't' => '',   // Number of days in the given month       28 through 31
        'L'     => '',   // Whether it's a leap year    1 if it is a leap year, 
0 otherwise.
        'o'     => '%G', // ISO-8601 year number. This has the same value as Y, 
except that if the ISO week number (W)
belongs to the previous or next year, that year is used instead. (added in PHP 
5.1.0)   Examples: 1999 or 2003
        'Y'     => '%Y', // A full numeric representation of a year, 4 digits   
Examples: 1999 or 2003
        'y'     => '%y', // A two digit representation of a year        
Examples: 99 or 03
        'a'     => '%p', // Lowercase Ante meridiem and Post meridiem   am or pm
        'A'     => '%p', // Uppercase Ante meridiem and Post meridiem   AM or PM
        'B'     => '',   // Swatch Internet time        000 through 999
        'g'     => '%I', // 12-hour format of an hour without leading zeros     
1 through 12
        'G'     => '%H', // 24-hour format of an hour without leading zeros     
0 through 23
        'h'     => '%I', // 12-hour format of an hour with leading zeros        
01 through 12
        'H'     => '%H', // 24-hour format of an hour with leading zeros        
00 through 23
        'i'     => '%M', // Minutes with leading zeros  00 to 59
        's'     => '%S', // Seconds, with leading zeros 00 through 59
        'e'     => '%Z', // Timezone identifier (added in PHP 5.1.0)    
Examples: UTC, GMT, Atlantic/Azores
        'I' => '',   // Whether or not the date is in daylight saving time      
1 if Daylight Saving Time, 0 otherwise.
        'O'     => '',   // Difference to Greenwich time (GMT) in hours 
Example: +0200
        'P'     => '',   // Difference to Greenwich time (GMT) with colon 
between hours and minutes (added in PHP 5.1.3)
Example: +02:00
        'T'     => '%z', // Timezone setting of this machine    Examples: EST, 
MDT ...
        'Z'     => '',   // Timezone offset in seconds. The offset for 
timezones west of UTC is always negative, and for
those east of UTC is always positive.   -43200 through 50400
        'c'     => '%c', // ISO 8601 date (added in PHP 5)      
2004-02-12T15:19:21+00:00
        'r'     => '%a, %m %b %Y %T', // RFC 2822 formatted date        
Example: Thu, 21 Dec 2000 16:01:07 +0200
        'U' => '', // Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
    );

    if (strpos($fmt, '%') === false) {
        $find = array_keys($dfMap);
        foreach ($find as $k => $v) {
            $find[$k] = '#(?<!%)'.$v.'#'; // negative lookbehind assertion 
(must not be preceeded by a % sign)
        }
        // try to convert date() format to strftime() format
        $fmt = preg_replace($find, array_values($dfMap), $fmt);
    }

    return $fmt;
}

--- End Message ---
--- Begin Message ---
On Wed, December 13, 2006 12:15 am, Kai Xiang wrote:
> 1. I heard there is a zend engine inside PHP playing the role as a
> virtual
> machine, and PHP excution have 2 step, first compile to opcode and
> then
> excute the opcode,
> so is that means the php are compiled only once per file? or still
> need to
> recompile when another request issued to the server? also I heard
> about the
> caching extention about php, is it talking about caching the opcode?
> is't
> caching the opcode or excute results? how it shares between the
> requests?

There is a Zend Engine inside the guts of PHP, and it does compile to
opcode and execute.

You can buy or find "opcode cache" software that will cache the
compiled opcode and run that on the next request.

Note that the BIG win there is not the compilation, but the hard drive
not getting hit to load in the PHP script.

> 2. Is there some alternative choise except zend engineen, why need a
> zend
> engine? for performance advantage or just easy for porting to
> different
> platform?

The original PHP guts were a hand-crafted parser by Rasmus Lerdorf,
who, and this is NOT meant to be pejorative, had no idea what he was
doing :-)
He didn't know that there were tools out there to write new computer
languages, and didn't use them.
So his parser was, well, kinda buggy, actually.
Ze'ev and Andi gutted the system with a shiny new parser using the pro
tools for homework, and ended up being Core PHP Developers by
accident. :-)
So, that became the Zend Engine, as Ze'ev and Andi's idea of a Good
Time is not building PHP websites, but building cool tools to improve
the guts of PHP, which is also why they started Zend (http://zend.com)
to sell high-end tools to high-end customers, like the Zend Cache.

> 3. Take linux apache for example, if compiled as a apache module, and
> using
> prefork threading model, for example, if I have 100 process, is that
> means I
> have 100 copy of PHP library local data(I assume only one reentrant
> excutable image) in each process? compare to a worker model, like 10
> process
> and 10 threads in each one process, should it make a difference that
> we only
> have 10 copy of PHP library local data ?

Yes, but if you don't use prefork, you have some serious thread safety
Risks, particularly in the extensions, and most especially in any
extensions that aren't getting heavy use already by people trying to
push into the threaded environment...

Stick with pre-fork unless your testing budget is 10 X your dev budget.

> I'm not sure if this is the right place to talk about this, anyway, if
> you
> know a better place, help me out :)

This is probably about as on-topic a post as one can get, though much
of the info is "out there" if you can sift through the junk to find
it.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

--- End Message ---
--- Begin Message ---
Hi,

I applogize if this isn't really related to php-programming, but it's related to
php.

I'm wondering if anyone knows what program sites like google video or break.com
use? is it a software like php-nuke, or phpBB or drupal? They all look pretty
much the same, so I'm guessing it's a package they use. Anyone know what it is?
or are they all really writing everything from scratch?

thanks,
Siavash

--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:
> Hi,
> 
> I applogize if this isn't really related to php-programming, but it's related 
> to
> php.
> 
> I'm wondering if anyone knows what program sites like google video or 
> break.com
> use? is it a software like php-nuke, or phpBB or drupal? They all look pretty
> much the same, so I'm guessing it's a package they use. Anyone know what it 
> is?
> or are they all really writing everything from scratch?

google video - running on php-nuke - no I don't think so.

they write from scratch, with the odd billion dollars lying around they can 
afford
to :-) (also note that youtube was bought by google for something like 1.3 
billion dollars -
I doubt they were stupid enough to shell out that kind of cash to on a php-nuke 
install,
even if they did seemingly buy themselves into litigation hell)

> 
> thanks,
> Siavash
> 

--- End Message ---
--- Begin Message ---
On Thu, 2006-12-14 at 23:40 +0100, Jochem Maas wrote:
> [EMAIL PROTECTED] wrote:
> > Hi,
> > 
> > I applogize if this isn't really related to php-programming, but it's 
> > related to
> > php.
> > 
> > I'm wondering if anyone knows what program sites like google video or 
> > break.com
> > use? is it a software like php-nuke, or phpBB or drupal? They all look 
> > pretty
> > much the same, so I'm guessing it's a package they use. Anyone know what it 
> > is?
> > or are they all really writing everything from scratch?
> 
> google video - running on php-nuke - no I don't think so.
> 
> they write from scratch, with the odd billion dollars lying around they can 
> afford
> to :-) (also note that youtube was bought by google for something like 1.3 
> billion dollars -


> I doubt they were stupid enough to shell out that kind of cash to on a 
> php-nuke install,

Why not? It's not the code they want, it's the traffic. You can have the
best code in the world and if 0 people visit it, it's pretty worthless
to anyone but you.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
Hi everyone,

Let me know if there is a better place to post this.

I am playing with the idea of creating a true (KISS) abstraction layer that makes full use of PHP5's OOP support. So logically it would make sense to make use PDO wherever possible, however, one of PDO's design decisions was to make a prepared statement object also a result set (another question: ... why?) a script can not make use of the a statement more than once without completely fetching all the data it needs from the first query, before executing the next.

A likely scenario is that the prepared statement is executed and then before the script is done with processing the result, the same statement (with different binds) will need to be executed again, also using the result set from that statement.

Does PDO provide a method to deal with this problem? From what I understand the only solution would be to prepare a new statement for each query, even for queries with the same structure which defeats the purpose of a prepared statement(?) Is there a solution that is a bit better?

Regards,

David

--- End Message ---
--- Begin Message ---
I'm trying to limit the text someone can submit in a text area with : 


Code:   
if(!preg_match("/^[א-תA-Za-z0-9_():,@\/\.\s\-\" ]*$/i",$FieldValue)) { 

}       


It works well but I'm having problems with the " (double quote). 
If there is a double quote (") it fails. 


--- End Message ---

Reply via email to