php-general Digest 19 Apr 2010 13:56:40 -0000 Issue 6701

Topics (messages 304189 through 304209):

Re: Mail Function Using PEAR Issues
        304189 by: Kevin Kinsey
        304190 by: Alice Wei
        304191 by: Karl DeSaulniers
        304192 by: Kevin Kinsey
        304194 by: Peter Lind
        304205 by: Alice Wei

Re: How to do i18n better?
        304193 by: Peter Lind
        304199 by: Michiel Sikma
        304202 by: Andre Polykanine
        304203 by: Per Jessen
        304209 by: Robert Cummings

Class constants
        304195 by: Gary .
        304196 by: Peter Lind
        304204 by: Gary .
        304206 by: Peter Lind
        304207 by: Ashley Sheridan

Get Power Saving Settings of the Server
        304197 by: kranthi
        304198 by: Richard

Re: PHP include security
        304200 by: Michiel Sikma

Re: Does PHP support multi-thread ?
        304201 by: Richard Quadling

Array to csv or excel in php
        304208 by: Manolis Vlachakis

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Karl DeSaulniers wrote:
Hey Alice,
Again, try throwing the MIME in.

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";

Also:

$headers .= 'Errors-to: <myworkingemailaddr...@foo.com>' . "\r\n";

  Which I suggested on your previous thread.  Also, I see you have
$from set to equal "localhost".  Many SMTP servers will reject this
I *think*, because "localhost" is a hostname, not a working mailbox.
Try making $from equal to a real working address - possibly the same
one as your "Errors-to:" header..

My $0.02,

KDK


On Apr 18, 2010, at 10:11 AM, Alice Wei wrote:


Hi,

After several days, I have rebuilt my system on Linux using Ubuntu, installed PEAR and such. Thankfully, when I execute the code, it no longer gives me the error that the class is not found. Yet, when I submit the form now, I can always see the confirmation message telling me that my message has been sent, but I cannot see it even in another mailbox.

Here is the code:

require_once("Mail.php");
$mail = Mail::factory("mail");

$your_name = $_POST['your_name'];
$email = $_POST['email'];
$question = $_POST['question'];
$comments= $_POST['comments'];
$submit = $_POST['submit'];

$from = "localhost";
$to =  $email;
$subject = "Comments";
$body = "From: $your_name\n E-Mail: $email\n Reason Contact: $question\n Comments:\n $comments";

$host = "localhost";
$headers = array ('From' => $from,'To' => $to,'Subject' => $subject);
$mail ->send($to, $headers, $body);
if (PEAR::isError($mail)) echo "<p>" . $mail->getMessage() . "</p>";
else {
       echo "<p>Message successfully sent!</p> <div id='main'>
       <h1>Thank You For Contacting Us</h1>
<p>We will contact you within the next <b>24 business hours</b>.</p>
       <p>Here is what you have input:</p>
       <ul><li>Your Name is <b>" . $your_name .  "</b></li>
           <li>Your Email is <b>" . $email . "</b></li>
<li>You contacted us because you have a <b>" . $question . "</b></li>
           <li>Here are your comments: <b>" . $comments . "</b></li></ul>
     <h1>Have a Nice Day!</h1></div>";
  }
}

Can anyone on the list please give me some pointers on what might have been wrong here? I have not edited anything in the php.ini file regarding SMTP.

Thanks.

Alice


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

> Date: Sun, 18 Apr 2010 21:02:29 -0500
> From: k...@daleco.biz
> To: aj...@alumni.iu.edu
> CC: k...@designdrumm.com; php-gene...@lists.php.net
> Subject: Re: [PHP] Mail Function Using PEAR Issues
> 
> Karl DeSaulniers wrote:
> > Hey Alice,
> > Again, try throwing the MIME in.
> > 
> > $headers  = 'MIME-Version: 1.0' . "\r\n";
> > $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
> 
> Also:
> 
> $headers .= 'Errors-to: <myworkingemailaddr...@foo.com>' . "\r\n";
> 
>    Which I suggested on your previous thread.  Also, I see you have
> $from set to equal "localhost".  Many SMTP servers will reject this
> I *think*, because "localhost" is a hostname, not a working mailbox.
> Try making $from equal to a real working address - possibly the same
> one as your "Errors-to:" header..
> 
> My $0.02,
> 
> KDK
> 
> > 
> > On Apr 18, 2010, at 10:11 AM, Alice Wei wrote:
> > 
> >>
> >> Hi,
> >>
> >>   After several days, I have rebuilt my system on Linux using Ubuntu, 
> >> installed PEAR and such. Thankfully, when I execute the code, it no 
> >> longer gives me the error that the class is not found. Yet, when I 
> >> submit the form now, I can always see the confirmation message telling 
> >> me that my message has been sent, but I cannot see it even in another 
> >> mailbox.
> >>
> >> Here is the code:
> >>
> >> require_once("Mail.php");
> >> $mail = Mail::factory("mail");
> >>
> >> $your_name = $_POST['your_name'];
> >> $email = $_POST['email'];
> >> $question = $_POST['question'];
> >> $comments= $_POST['comments'];
> >> $submit = $_POST['submit'];
> >>
> >> $from = "localhost";
> >> $to =  $email;
> >> $subject = "Comments";
> >> $body = "From: $your_name\n E-Mail: $email\n Reason Contact: 
> >> $question\n Comments:\n $comments";
> >>
> >> $host = "localhost";
> >> $headers = array ('From' => $from,'To' => $to,'Subject' => $subject);
> >> $mail ->send($to, $headers, $body);
> >> if (PEAR::isError($mail)) echo "<p>" . $mail->getMessage() . "</p>";
> >> else {
> >>        echo "<p>Message successfully sent!</p> <div id='main'>
> >>        <h1>Thank You For Contacting Us</h1>
> >>        <p>We will contact you within the next <b>24 business 
> >> hours</b>.</p>
> >>        <p>Here is what you have input:</p>
> >>        <ul><li>Your Name is <b>" . $your_name .  "</b></li>
> >>            <li>Your Email is <b>" . $email . "</b></li>
> >>            <li>You contacted us because you have a <b>" . $question . 
> >> "</b></li>
> >>            <li>Here are your comments: <b>" . $comments . "</b></li></ul>
> >>      <h1>Have a Nice Day!</h1></div>";
> >>   }
> >> }
> >>
> >> Can anyone on the list please give me some pointers on what might have 
> >> been wrong here? I have not edited anything in the php.ini file 
> >> regarding SMTP.
> >>
> >> Thanks.
> >>
> >> Alice
> 

Hi, 

Here is the revised version, and I don't think I have experienced any changes 
in terms of the output on the screen. Plus, I still get no email. 

<?php

require_once("Mail.php");

$mail = Mail::factory("mail");



$your_name = $_POST['your_name'];

$email = $_POST['email'];

$question = $_POST['question'];

$comments= $_POST['comments'];

$submit = $_POST['submit'];



$from = "aj...@alumni.iu.edu";

$to =  "elite.engl...@gmail.com";

$subject = "Comments";

$body = "From: $your_name\n E-Mail: $email\n Reason Contact: $question\n
 Comments:\n $comments";



$headers =  'MIME-Version: 1.0' . "\r\n";

$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";

$headers .= 'Errors-to: <elite.engl...@gmail.com>' . "\r\n";

$mail ->send($to, $headers, $body);

if (PEAR::isError($mail)) echo "<p>" . $mail->getMessage() . 
"</p>";

else {

       echo "<p>Message successfully sent!</p> <div 
id='main'> 

       <h1>Thank You For Contacting Us</h1>

       <p>Here is what you have input:</p>

       <ul><li>Your Name is <b>" . $your_name .  
"</b></li>

           <li>Your Email is <b>" . $email . 
"</b></li>

           <li>You contacted us because you have a <b>" . 
$question . "</b></li>

           <li>Here are your comments: <b>" . $comments . 
"</b></li></ul>

     <h1>Have a Nice Day!</h1></div>";

  } 


I have made sure that my $from and $to addresses are different, Could there be 
anything else wrong here? I have not edited anything in php.ini regarding this 
issue. Would I need to?

Thanks for your help.

Alice
                                          
_________________________________________________________________
The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail.
http://www.windowslive.com/campaign/thenewbusy?tile=multiaccount&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4

--- End Message ---
--- Begin Message ---
Is there any need for this line if you are using the Errors-to:  ?
Maybe take it out and see what Errors-to gives you without it.


On Apr 18, 2010, at 9:27 PM, Alice Wei wrote:


if (PEAR::isError($mail)) echo "<p>" . $mail->getMessage() .




OAN - That sendmail script I posted, I know works on Linux servers if you want to compare notes with it.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


--- End Message ---
--- Begin Message ---
Alice Wei wrote:

Date: Sun, 18 Apr 2010 21:02:29 -0500
From: k...@daleco.biz
To: aj...@alumni.iu.edu
CC: k...@designdrumm.com; php-gene...@lists.php.net
Subject: Re: [PHP] Mail Function Using PEAR Issues

Karl DeSaulniers wrote:
Hey Alice,
Again, try throwing the MIME in.

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
Also:

$headers .= 'Errors-to: <myworkingemailaddr...@foo.com>' . "\r\n";

   Which I suggested on your previous thread.  Also, I see you have
$from set to equal "localhost".  Many SMTP servers will reject this
I *think*, because "localhost" is a hostname, not a working mailbox.
Try making $from equal to a real working address - possibly the same
one as your "Errors-to:" header..

My $0.02,

KDK

On Apr 18, 2010, at 10:11 AM, Alice Wei wrote:

Hi,

After several days, I have rebuilt my system on Linux using Ubuntu, installed PEAR and such. Thankfully, when I execute the code, it no longer gives me the error that the class is not found. Yet, when I submit the form now, I can always see the confirmation message telling me that my message has been sent, but I cannot see it even in another mailbox.

Here is the code:

require_once("Mail.php");
$mail = Mail::factory("mail");

$your_name = $_POST['your_name'];
$email = $_POST['email'];
$question = $_POST['question'];
$comments= $_POST['comments'];
$submit = $_POST['submit'];

$from = "localhost";
$to =  $email;
$subject = "Comments";
$body = "From: $your_name\n E-Mail: $email\n Reason Contact: $question\n Comments:\n $comments";

$host = "localhost";
$headers = array ('From' => $from,'To' => $to,'Subject' => $subject);
$mail ->send($to, $headers, $body);
if (PEAR::isError($mail)) echo "<p>" . $mail->getMessage() . "</p>";
else {
       echo "<p>Message successfully sent!</p> <div id='main'>
       <h1>Thank You For Contacting Us</h1>
<p>We will contact you within the next <b>24 business hours</b>.</p>
       <p>Here is what you have input:</p>
       <ul><li>Your Name is <b>" . $your_name .  "</b></li>
           <li>Your Email is <b>" . $email . "</b></li>
<li>You contacted us because you have a <b>" . $question . "</b></li>
           <li>Here are your comments: <b>" . $comments . "</b></li></ul>
     <h1>Have a Nice Day!</h1></div>";
  }
}

Can anyone on the list please give me some pointers on what might have been wrong here? I have not edited anything in the php.ini file regarding SMTP.

Thanks.

Alice

Hi, Here is the revised version, and I don't think I have experienced any
> changes in terms of the output on the screen. Plus, I still get no email.

<?php

require_once("Mail.php");
$mail = Mail::factory("mail");
$your_name = $_POST['your_name'];
$email = $_POST['email'];
$question = $_POST['question'];
$comments= $_POST['comments'];
$submit = $_POST['submit'];
$from = "aj...@alumni.iu.edu";
$to =  "elite.engl...@gmail.com";
$subject = "Comments";

$body = "From: $your_name\n E-Mail: $email\n Reason Contact: $question\n
Comments:\n $comments";
$headers =  'MIME-Version: 1.0' . "\r\n";

$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";

$headers .= 'Errors-to: <elite.engl...@gmail.com>' . "\r\n";

$mail ->send($to, $headers, $body);

if (PEAR::isError($mail)) echo "<p>" . $mail->getMessage() . "</p>";

else {

echo "<p>Message successfully sent!</p> <div id='main'>
       <h1>Thank You For Contacting Us</h1>

       <p>Here is what you have input:</p>

<ul><li>Your Name is <b>" . $your_name . "</b></li>

<li>Your Email is <b>" . $email . "</b></li>

<li>You contacted us because you have a <b>" . $question . "</b></li>

<li>Here are your comments: <b>" . $comments . "</b></li></ul>

     <h1>Have a Nice Day!</h1></div>";

} I have made sure that my $from and $to addresses are different,
> Could there be anything else wrong here? I have not edited
> anything in php.ini regarding this issue. Would I need to?

Well, it's a Good Thing(tm) to know what those settings are.
Have they changed since your last thread?

KDK


--- End Message ---
--- Begin Message ---
Most, if not all, mail servers keep log files. You should look for the
log files to see if the mail server has sent your mail properly or is
experiencing problems (those may not feed back into PHP).

Regards
Peter

-- 
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
</hype>

--- End Message ---
--- Begin Message ---
 > Date: Sun, 18 Apr 2010 21:39:19 -0500
> From: k...@daleco.biz
> To: aj...@alumni.iu.edu
> CC: k...@designdrumm.com; php-gene...@lists.php.net
> Subject: Re: [PHP] Mail Function Using PEAR Issues
> 
> Alice Wei wrote:
> > 
> >> Date: Sun, 18 Apr 2010 21:02:29 -0500
> >> From: k...@daleco.biz
> >> To: aj...@alumni.iu.edu
> >> CC: k...@designdrumm.com; php-gene...@lists.php.net
> >> Subject: Re: [PHP] Mail Function Using PEAR Issues
> >>
> >> Karl DeSaulniers wrote:
> >>> Hey Alice,
> >>> Again, try throwing the MIME in.
> >>>
> >>> $headers  = 'MIME-Version: 1.0' . "\r\n";
> >>> $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
> >> Also:
> >>
> >> $headers .= 'Errors-to: <myworkingemailaddr...@foo.com>' . "\r\n";
> >>
> >>    Which I suggested on your previous thread.  Also, I see you have
> >> $from set to equal "localhost".  Many SMTP servers will reject this
> >> I *think*, because "localhost" is a hostname, not a working mailbox.
> >> Try making $from equal to a real working address - possibly the same
> >> one as your "Errors-to:" header..
> >>
> >> My $0.02,
> >>
> >> KDK
> >>
> >>> On Apr 18, 2010, at 10:11 AM, Alice Wei wrote:
> >>>
> >>>> Hi,
> >>>>
> >>>>   After several days, I have rebuilt my system on Linux using Ubuntu, 
> >>>> installed PEAR and such. Thankfully, when I execute the code, it no 
> >>>> longer gives me the error that the class is not found. Yet, when I 
> >>>> submit the form now, I can always see the confirmation message telling 
> >>>> me that my message has been sent, but I cannot see it even in another 
> >>>> mailbox.
> >>>>
> >>>> Here is the code:
> >>>>
> >>>> require_once("Mail.php");
> >>>> $mail = Mail::factory("mail");
> >>>>
> >>>> $your_name = $_POST['your_name'];
> >>>> $email = $_POST['email'];
> >>>> $question = $_POST['question'];
> >>>> $comments= $_POST['comments'];
> >>>> $submit = $_POST['submit'];
> >>>>
> >>>> $from = "localhost";
> >>>> $to =  $email;
> >>>> $subject = "Comments";
> >>>> $body = "From: $your_name\n E-Mail: $email\n Reason Contact: 
> >>>> $question\n Comments:\n $comments";
> >>>>
> >>>> $host = "localhost";
> >>>> $headers = array ('From' => $from,'To' => $to,'Subject' => $subject);
> >>>> $mail ->send($to, $headers, $body);
> >>>> if (PEAR::isError($mail)) echo "<p>" . $mail->getMessage() . "</p>";
> >>>> else {
> >>>>        echo "<p>Message successfully sent!</p> <div id='main'>
> >>>>        <h1>Thank You For Contacting Us</h1>
> >>>>        <p>We will contact you within the next <b>24 business 
> >>>> hours</b>.</p>
> >>>>        <p>Here is what you have input:</p>
> >>>>        <ul><li>Your Name is <b>" . $your_name .  "</b></li>
> >>>>            <li>Your Email is <b>" . $email . "</b></li>
> >>>>            <li>You contacted us because you have a <b>" . $question . 
> >>>> "</b></li>
> >>>>            <li>Here are your comments: <b>" . $comments . "</b></li></ul>
> >>>>      <h1>Have a Nice Day!</h1></div>";
> >>>>   }
> >>>> }
> >>>>
> >>>> Can anyone on the list please give me some pointers on what might have 
> >>>> been wrong here? I have not edited anything in the php.ini file 
> >>>> regarding SMTP.
> >>>>
> >>>> Thanks.
> >>>>
> >>>> Alice
> > 
> > Hi, 
> > 
> > Here is the revised version, and I don't think I have experienced any  
>  > changes in terms of the output on the screen. Plus, I still get no email.
> > 
> > <?php
> > 
> > require_once("Mail.php");
> > $mail = Mail::factory("mail");
> > $your_name = $_POST['your_name'];
> > $email = $_POST['email'];
> > $question = $_POST['question'];
> > $comments= $_POST['comments'];
> > $submit = $_POST['submit'];
> > $from = "aj...@alumni.iu.edu";
> > $to =  "elite.engl...@gmail.com";
> > $subject = "Comments";
> > 
> > $body = "From: $your_name\n E-Mail: $email\n Reason Contact: $question\n
> >  Comments:\n $comments"; 
> > 
> > $headers =  'MIME-Version: 1.0' . "\r\n";
> > 
> > $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
> > 
> > $headers .= 'Errors-to: <elite.engl...@gmail.com>' . "\r\n";
> > 
> > $mail ->send($to, $headers, $body);
> > 
> > if (PEAR::isError($mail)) echo "<p>" . $mail->getMessage() . 
> > "</p>";
> > 
> > else {
> > 
> >        echo "<p>Message successfully sent!</p> <div 
> > id='main'> 
> > 
> >        <h1>Thank You For Contacting Us</h1>
> > 
> >        <p>Here is what you have input:</p>
> > 
> >        <ul><li>Your Name is <b>" . $your_name .  
> > "</b></li>
> > 
> >            <li>Your Email is <b>" . $email . 
> > "</b></li>
> > 
> >            <li>You contacted us because you have a <b>" . 
> > $question . "</b></li>
> > 
> >            <li>Here are your comments: <b>" . $comments . 
> > "</b></li></ul>
> > 
> >      <h1>Have a Nice Day!</h1></div>";
> > 
> >   } 
> > 
> > I have made sure that my $from and $to addresses are different, 
>  > Could there be anything else wrong here? I have not edited
>  > anything in php.ini regarding this issue. Would I need to?
> 
> Well, it's a Good Thing(tm) to know what those settings are.
> Have they changed since your last thread?
> 

I have not changed any of my SMTP settings since my new installation of 
PHP with Pear. So, I am not sure what the settings are supposed to be. 
Would I need to install anything else even when the Pear Mail package 
has been installed?

Alice
                                          
_________________________________________________________________
The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with 
Hotmail. 
http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5

--- End Message ---
--- Begin Message ---
Consider checking out http://php.net/gettext - it's the set of
functions in PHP for i18n.

With regards to language switching, you should consider using a url
hierarchy for it, instead of just serving all pages with changing
content.

Regards
Peter

-- 
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
</hype>

--- End Message ---
--- Begin Message ---
On 19 April 2010 00:55, Andre Polykanine <an...@oire.org> wrote:

>
> Now the i18n process is made as follows: we set a cookie on the site
> and depending on it we select the language to display the site in. We
> have three (currently) interface files: rus.lng, ukr.lng, and enu.lng
> (for English US). the format is the following:
> define ("MSG379", "Welcome!");
>
>
You might want to consider making the language dependent on the URL, e.g.
http://site.com/ru/pagename for Russian. Doing it this way certainly isn't a
bad solution, but I do strongly recommend against using define() and using
anonymous translation keys. Usually, you have one base language (which is
usually English due to its lack of special characters and ubiquity) from
which you work. You then either simplify your keys, e.g. 'user_welcome' =>
'Welcome, %1$s!', or make the keys the proper base language strings so you
can wrap everything in a language function.

In the latter case, you might have something like <p><?= _('Welcome, %1$s!',
$username); ?></p>, and then if the current language is not English, the _()
function will make the appropriate lookup.

The advantage of this is you won't need to have a tertiary source to tell
you which MSG### corresponds to which piece of text.

Michiel

--- End Message ---
--- Begin Message ---
Hello Peter,

Regarding the URL switching suggested by you and Michiel, how do I do
this if I have a rather complicated .htaccess file? For instance, a
blog entry URL is formed as follows:
http://oire.org/menelion/entry/190/ which is phisically
http://oire.org/oire.php?o=menelion&e=190
If I need to insert the locale somewhere inhere, sorry, I just don't
know how to do that)
-- 
With best regards from Ukraine,
Andre
Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @ 
jabber.org
Yahoo! messenger: andre.polykanine; ICQ: 191749952
Twitter: m_elensule

----- Original message -----
From: Peter Lind <peter.e.l...@gmail.com>
To: Andre Polykanine <an...@oire.org>
Date: Monday, April 19, 2010, 11:10:59 AM
Subject: [PHP] How to do i18n better?

Consider checking out http://php.net/gettext - it's the set of
functions in PHP for i18n.

With regards to language switching, you should consider using a url
hierarchy for it, instead of just serving all pages with changing
content.

Regards
Peter

-- 
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
</hype>


--- End Message ---
--- Begin Message ---
Andre Polykanine wrote:

> etc. I know that PHP does support somehow exporting the strings into a
> .pod file. Maybe it would be better to do that? If so, how can I do
> it?
> Could you suggest me maybe a better solution than we currently have?

For mostly dynamic messages or pages, I would take a look at the
gettext() mechanism:

http://php.net/manual/en/book.gettext.php



-- 
Per Jessen, Zürich (14.9°C)


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


Michiel Sikma wrote:
On 19 April 2010 00:55, Andre Polykanine <an...@oire.org> wrote:

Now the i18n process is made as follows: we set a cookie on the site
and depending on it we select the language to display the site in. We
have three (currently) interface files: rus.lng, ukr.lng, and enu.lng
(for English US). the format is the following:
define ("MSG379", "Welcome!");


You might want to consider making the language dependent on the URL, e.g.
http://site.com/ru/pagename for Russian. Doing it this way certainly isn't a
bad solution, but I do strongly recommend against using define() and using
anonymous translation keys. Usually, you have one base language (which is
usually English due to its lack of special characters and ubiquity) from
which you work. You then either simplify your keys, e.g. 'user_welcome' =>
'Welcome, %1$s!', or make the keys the proper base language strings so you
can wrap everything in a language function.

In the latter case, you might have something like <p><?= _('Welcome, %1$s!',
$username); ?></p>, and then if the current language is not English, the _()
function will make the appropriate lookup.

Unless you have namespaces (and I can't remember if they completed namespaced based functions) then don't use something so commuon as a function named underscore :/

Cheers,
Rob.


--- End Message ---
--- Begin Message ---
Should I be able to do this:

class X
{
  const FOO = 'foo';
  const FOOBAR = X::FOO . 'bar';

...
}

?

Because I can't. I get "syntax error, unexpected '.', expecting ',' or
';'". I assume this is because the constants are like statics which
can't be initialised by functions etc. but is there really any logic
behind this?

--- End Message ---
--- Begin Message ---
On 19 April 2010 10:30, Gary . <php-gene...@garydjones.name> wrote:
> Should I be able to do this:
>
> class X
> {
>  const FOO = 'foo';
>  const FOOBAR = X::FOO . 'bar';
>
> ...
> }
>
> ?
>
> Because I can't. I get "syntax error, unexpected '.', expecting ',' or
> ';'". I assume this is because the constants are like statics which
> can't be initialised by functions etc. but is there really any logic
> behind this?
>

It very often pays to read the PHP docs. From
http://pl.php.net/manual/en/language.oop5.constants.php :
"The value must be a constant expression, not (for example) a
variable, a property, a result of a mathematical operation, or a
function call. "

So no, you shouldn't be able to do that.

-- 
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
</hype>

--- End Message ---
--- Begin Message ---
On Mon, Apr 19, 2010 at 10:36 AM, Peter Lind wrote:
> On 19 April 2010 10:30, Gary wrote:
>> Should I be able to do this:
>>
>> class X
>> {
>>  const FOO = 'foo';
>>  const FOOBAR = X::FOO . 'bar';
>>
>> ...
>> }

> So no, you shouldn't be able to do that.

Okay. Why not?

--- End Message ---
--- Begin Message ---
On 19 April 2010 14:24, Gary . <php-gene...@garydjones.name> wrote:
> On Mon, Apr 19, 2010 at 10:36 AM, Peter Lind wrote:
>> On 19 April 2010 10:30, Gary wrote:
>>> Should I be able to do this:
>>>
>>> class X
>>> {
>>>  const FOO = 'foo';
>>>  const FOOBAR = X::FOO . 'bar';
>>>
>>> ...
>>> }
>
>> So no, you shouldn't be able to do that.
>
> Okay. Why not?

Hate to ask, but did you at any point consider to read the PHP docs on
this? The bit I sent or what you could gather from the link posted?

-- 
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
</hype>

--- End Message ---
--- Begin Message ---
On Mon, 2010-04-19 at 14:37 +0200, Peter Lind wrote:

> On 19 April 2010 14:24, Gary . <php-gene...@garydjones.name> wrote:
> > On Mon, Apr 19, 2010 at 10:36 AM, Peter Lind wrote:
> >> On 19 April 2010 10:30, Gary wrote:
> >>> Should I be able to do this:
> >>>
> >>> class X
> >>> {
> >>>  const FOO = 'foo';
> >>>  const FOOBAR = X::FOO . 'bar';
> >>>
> >>> ...
> >>> }
> >
> >> So no, you shouldn't be able to do that.
> >
> > Okay. Why not?
> 
> Hate to ask, but did you at any point consider to read the PHP docs on
> this? The bit I sent or what you could gather from the link posted?
> 
> -- 
> <hype>
> WWW: http://plphp.dk / http://plind.dk
> LinkedIn: http://www.linkedin.com/in/plind
> Flickr: http://www.flickr.com/photos/fake51
> BeWelcome: Fake51
> Couchsurfing: Fake51
> </hype>
> 


Class constants must be defined with static values, not variables. They
are constants after all! If they relied on the value of a variable,
surely that would mean that their own value might change, so they would
just become regular variables not constants.

Is there a specific reason that you need to try and achieve this? Would
it not be better to have private or protected variables using getters
and setters if you need variable values?

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
Hi all,
My PHP script is running as CLI. Can I get the Power Management
Settings of the server ?

I am using PHP 5.3.2 on Fedora 12 Machine (2.6.32.10-90.fc12.i686)


KK.

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

> My PHP script is running as CLI. Can I get the Power Management
> Settings of the server ?
>
> I am using PHP 5.3.2 on Fedora 12 Machine (2.6.32.10-90.fc12.i686)

Your server management software may provide a way to get this
information either through the command line or through a network
interface. SNMP may also provide this information, and ISTR there's a
PHP SNMP module. Enjoy... :-)

-- 
Richard Heyes
HTML5 canvas graphing: RGraph - http://www.rgraph.net (updated 10th April)
Lots of PHP and Javascript code - http://www.phpguru.org

--- End Message ---
--- Begin Message ---
On 18 April 2010 21:43, Micky Hulse <mickyhulse.li...@gmail.com> wrote:

> On Sun, Apr 18, 2010 at 10:23 AM, Michiel Sikma <mich...@thingmajig.org>
> wrote:
> > I would prefer to use include() since it runs the code in the same
> context,
> > ...<snip>...
> > with your data rather than printing it right away.
>
> Thanks for the reply Michiel, I really appreciate it. :)
>
> For some benchmarks on the different types of inclusion
> functions/language constructs, this page has some good info:
>
> <http://www.raditha.com/wiki/Readfile_vs_include>
>
> The results are interesting.
>
>
One thing to keep in mind is that this one doesn't take eval() vs regular
include execution time into account, in case you were still considering
using it. According to this page, it's many times slower:
http://blog.joshuaeichorn.com/archives/2005/08/01/using-eval-in-php/

Michiel

--- End Message ---
--- Begin Message ---
On 18 April 2010 14:17, ttplayer <f...@qq.com> wrote:
> Hello, everyone, please answer me. Thank you.
>  Does PHP support multi-thread ?

As you've been informed, PHP doesn't natively support threading.

But, the issue of forking was mentioned. I'm on Windows, and by using
a combination of MS's WinCache (I'm using V1.1.0412.0), with an
environment variable APP_POOL_ID set to something nice and unique
(i.e. not set to one used in IIS), and ...

  $WshShell = new COM("WScript.Shell");
  $oExec = $WshShell->Run($script . $params, 0, false);

you can successfully run a child script (or __FILE__ . ' /child:$Child
' . $params  sort of thing) and use wincache to pass data between the
parent and the children scripts.

This is working really well for me with the minor exception of having
to create the env var up front.

Ideally, I'd like to use the fallback logic of having the child script
use the parent process id as the identifier, but here the issue is is
that the parent script will also use the parent process, so no parent
child comms.... http://pecl.php.net/bugs/bug.php?id=17214

But, if you use APP_POOL_ID, then you'll be just fine.

Of course, if you are not on windows, then other techniques can be
used to simulate this (pcntl, proc_open() - maybe), but I don't know
enough to recommend one over the other.


-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--- End Message ---
--- Begin Message ---
hallo there everyone..
i got an array from my database
Help with Code 
Tags<http://www.daniweb.com/forums/misc-explaincode.html?TB_iframe=true&height=400&width=680>
*PHP Syntax* (Toggle Plain Text<http://www.daniweb.com/forums/post1194347.html#>
)


   1. $save=split("[|;]",$listOfItems);


and what i want i s after making some changes to the attributes on the array
above to export them on an csv or excel format
but directly as a message to the browser ..
i dont want it to be saved on the server ...
what i cant understand from the examples i found on the net ..
is how to handle the files and which are created cause
i just have the array in a php file nothing more...


another thing i have in mind is to export from the ldap server the files
directly but seems to me as the wrong way to do it

thanks

--- End Message ---

Reply via email to