php-general Digest 19 Apr 2010 01:51:51 -0000 Issue 6700

Topics (messages 304171 through 304188):

Does PHP support multi-thread ?
        304171 by: ttplayer
        304172 by: Angus Mann
        304173 by: Phpster
        304176 by: Nathan Rixham
        304181 by: Hans Åhlin

Re: Replacing a special character
        304174 by: Phpster
        304175 by: Peter Lind
        304178 by: Michiel Sikma
        304182 by: Michael Stroh
        304183 by: Mari Masuda
        304184 by: Michael Stroh

Mail Function Using PEAR Issues
        304177 by: Alice Wei
        304186 by: Karl DeSaulniers

Re: PHP include security
        304179 by: Michiel Sikma
        304185 by: Micky Hulse

Re: solution
        304180 by: Michiel Sikma

How to do i18n better?
        304187 by: Andre Polykanine
        304188 by: Robert Cummings

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 ---
Hello, everyone, please answer me. Thank you.
 Does PHP support multi-thread ?

--- End Message ---
--- Begin Message ---
Oh No !

Not again !

Pleeeeease !!

This was the subject of a very long and heated discussion a while ago.
No - it does not support multi threading.


----- Original Message ----- From: "ttplayer" <[email protected]>
To: "php-general" <[email protected]>
Sent: Sunday, April 18, 2010 11:17 PM
Subject: [PHP] Does PHP support multi-thread ?


Hello, everyone, please answer me. Thank you.
Does PHP support multi-thread ?

--- End Message ---
--- Begin Message --- Not all libraries are thread safe, so no. 2 seconds with a google search would have given you the same answer.

Bastien

Sent from my iPod

On Apr 18, 2010, at 9:17 AM, "ttplayer" <[email protected]> wrote:

Hello, everyone, please answer me. Thank you.
Does PHP support multi-thread ?

--- End Message ---
--- Begin Message ---
yup, check out forking though for related

Phpster wrote:
> Not all libraries are thread safe, so no. 2 seconds with a google search
> would have given you the same answer.
> 
> Bastien
> 
> Sent from my iPod
> 
> On Apr 18, 2010, at 9:17 AM, "ttplayer" <[email protected]> wrote:
> 
>> Hello, everyone, please answer me. Thank you.
>> Does PHP support multi-thread ?


--- End Message ---
--- Begin Message ---
2010/4/18 Angus Mann <[email protected]>:
> Oh No !
>
> Not again !
>
> Pleeeeease !!
>
> This was the subject of a very long and heated discussion a while ago.
> No - it does not support multi threading.
>

+1

>
> ----- Original Message ----- From: "ttplayer" <[email protected]>
> To: "php-general" <[email protected]>
> Sent: Sunday, April 18, 2010 11:17 PM
> Subject: [PHP] Does PHP support multi-thread ?
>
>
>> Hello, everyone, please answer me. Thank you.
>> Does PHP support multi-thread ?

ttplayer: here is the subject if you want to read more "[PHP] Will PHP
ever "grow up" and have threading?". it got 257+ replys ;)

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


**********************************************
 Hans Åhlin
   Tel: +46761488019
   http://www.kronan-net.com/
   irc://irc.freenode.net:6667 - TheCoin
**********************************************

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


On Apr 18, 2010, at 8:59 AM, Michael Stroh <[email protected]> wrote:

I have this form that people use to add entries into a MySQL database. Recently I've had some users insert − in their entries ins tead of - which is causing some issues with scripts down the line. I 'd like to replace the − character with -.

Originally I had something like

$name = mysql_escape_string($_POST["name"]);

which would convert the offending character to &#8722; before entering it into the database. It's this encoding that is causing the problems since some scripts send out emails with this entry in their subject line which looks messy.

I've tried adding the following line after the previous line to help fix this issue, however, I just got another entry with the same problem.

preg_replace('/&#8722;/','-',$name);

Any suggestions on how others would fix this problem? I'd just like to fix it before the entry hits the database instead of creating fixes on the other end of things.


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


One option is to send an HTML email which would have the email reader interpret that code correctly

Bastien

--- End Message ---
--- Begin Message ---
On 18 April 2010 16:40, Phpster <[email protected]> wrote:
>
>
> On Apr 18, 2010, at 8:59 AM, Michael Stroh <[email protected]> wrote:
>
>> I have this form that people use to add entries into a MySQL database.
>> Recently I've had some users insert − in their entries instead of - which is
>> causing some issues with scripts down the line. I'd like to replace the −
>> character with -.
>>
>> Originally I had something like
>>
>> $name = mysql_escape_string($_POST["name"]);
>>
>> which would convert the offending character to &#8722; before entering it
>> into the database. It's this encoding that is causing the problems since
>> some scripts send out emails with this entry in their subject line which
>> looks messy.
>>
>> I've tried adding the following line after the previous line to help fix
>> this issue, however, I just got another entry with the same problem.
>>
>> preg_replace('/&#8722;/','-',$name);
>>
>> Any suggestions on how others would fix this problem? I'd just like to fix
>> it before the entry hits the database instead of creating fixes on the other
>> end of things.
>>
>>
>> Cheers,
>> Michael
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
> One option is to send an HTML email which would have the email reader
> interpret that code correctly
>
> Bastien

Another option would be to use mysql_real_escape_string and make sure
that your code and the database are using utf-8. Then when the email
is sent, make sure that uses utf-8 as well.

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 18 April 2010 16:46, Peter Lind <[email protected]> wrote:

> On 18 April 2010 16:40, Phpster <[email protected]> wrote:
> >
> >
> > On Apr 18, 2010, at 8:59 AM, Michael Stroh <[email protected]> wrote:
> >
> >> I have this form that people use to add entries into a MySQL database.
> >> Recently I've had some users insert − in their entries instead of -
> which is
> >> causing some issues with scripts down the line. I'd like to replace the
> −
> >> character with -.
> >>
> >> Originally I had something like
> >>
> >> $name = mysql_escape_string($_POST["name"]);
> >>
> >> which would convert the offending character to &#8722; before entering
> it
> >> into the database. It's this encoding that is causing the problems since
> >> some scripts send out emails with this entry in their subject line which
> >> looks messy.
> >>
> >> I've tried adding the following line after the previous line to help fix
> >> this issue, however, I just got another entry with the same problem.
> >>
> >> preg_replace('/&#8722;/','-',$name);
> >>
> >> Any suggestions on how others would fix this problem? I'd just like to
> fix
> >> it before the entry hits the database instead of creating fixes on the
> other
> >> end of things.
> >>
> >>
> >> Cheers,
> >> Michael
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >
> > One option is to send an HTML email which would have the email reader
> > interpret that code correctly
> >
> > Bastien
>
> Another option would be to use mysql_real_escape_string and make sure
> that your code and the database are using utf-8. Then when the email
> is sent, make sure that uses utf-8 as well.
>
> Regards
> Peter
>
>
Make sure the database connection is also utf8:

set names 'utf8';

Typically, you should keep everything in utf8 unless you have a very good
reason not to.
And as Peter mentioned, the proper way to escape MySQL inserts (that is, if
you're not already using a framework that does this competently) is
mysql_real_escape_string().

Michiel

--- End Message ---
--- Begin Message ---
Thanks for the advice. I've changed the code to use mysql_real_escape_string. 
So now it is

  $name = mysql_real_escape_string($name);
  preg_replace('/&#8722;/','-',$name);

but it's still not replacing the &#8722; string. I've also changed the field in 
the database so that now it is using the collation utf8_general_ci. I've also 
tried

  preg_replace('/−/','-',$name);
  $name = mysql_real_escape_string($name);
  preg_replace('/&#8722;/','-',$name);

and that also did not work. Any ideas?

Michael



On Apr 18, 2010, at 1:08 PM, Michiel Sikma wrote:

> On 18 April 2010 16:46, Peter Lind <[email protected]> wrote:
> 
>> On 18 April 2010 16:40, Phpster <[email protected]> wrote:
>>> 
>>> 
>>> On Apr 18, 2010, at 8:59 AM, Michael Stroh <[email protected]> wrote:
>>> 
>>>> I have this form that people use to add entries into a MySQL database.
>>>> Recently I've had some users insert − in their entries instead of -
>> which is
>>>> causing some issues with scripts down the line. I'd like to replace the
>> −
>>>> character with -.
>>>> 
>>>> Originally I had something like
>>>> 
>>>> $name = mysql_escape_string($_POST["name"]);
>>>> 
>>>> which would convert the offending character to &#8722; before entering
>> it
>>>> into the database. It's this encoding that is causing the problems since
>>>> some scripts send out emails with this entry in their subject line which
>>>> looks messy.
>>>> 
>>>> I've tried adding the following line after the previous line to help fix
>>>> this issue, however, I just got another entry with the same problem.
>>>> 
>>>> preg_replace('/&#8722;/','-',$name);
>>>> 
>>>> Any suggestions on how others would fix this problem? I'd just like to
>> fix
>>>> it before the entry hits the database instead of creating fixes on the
>> other
>>>> end of things.
>>>> 
>>>> 
>>>> Cheers,
>>>> Michael
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>> 
>>> 
>>> One option is to send an HTML email which would have the email reader
>>> interpret that code correctly
>>> 
>>> Bastien
>> 
>> Another option would be to use mysql_real_escape_string and make sure
>> that your code and the database are using utf-8. Then when the email
>> is sent, make sure that uses utf-8 as well.
>> 
>> Regards
>> Peter
>> 
>> 
> Make sure the database connection is also utf8:
> 
> set names 'utf8';
> 
> Typically, you should keep everything in utf8 unless you have a very good
> reason not to.
> And as Peter mentioned, the proper way to escape MySQL inserts (that is, if
> you're not already using a framework that does this competently) is
> mysql_real_escape_string().
> 
> Michiel


--- End Message ---
--- Begin Message ---
Maybe you could try to assign the return value of preg_replace to a variable so 
you can use it later, like: 

$name = preg_replace('/&#8722;/','-',$name);


On Apr 18, 2010, at 11:38 AM, Michael Stroh wrote:

> Thanks for the advice. I've changed the code to use mysql_real_escape_string. 
> So now it is
> 
>  $name = mysql_real_escape_string($name);
>  preg_replace('/&#8722;/','-',$name);
> 
> but it's still not replacing the &#8722; string. I've also changed the field 
> in the database so that now it is using the collation utf8_general_ci. I've 
> also tried
> 
>  preg_replace('/−/','-',$name);
>  $name = mysql_real_escape_string($name);
>  preg_replace('/&#8722;/','-',$name);
> 
> and that also did not work. Any ideas?
> 
> Michael
> 
> 
> 
> On Apr 18, 2010, at 1:08 PM, Michiel Sikma wrote:
> 
>> On 18 April 2010 16:46, Peter Lind <[email protected]> wrote:
>> 
>>> On 18 April 2010 16:40, Phpster <[email protected]> wrote:
>>>> 
>>>> 
>>>> On Apr 18, 2010, at 8:59 AM, Michael Stroh <[email protected]> wrote:
>>>> 
>>>>> I have this form that people use to add entries into a MySQL database.
>>>>> Recently I've had some users insert − in their entries instead of -
>>> which is
>>>>> causing some issues with scripts down the line. I'd like to replace the
>>> −
>>>>> character with -.
>>>>> 
>>>>> Originally I had something like
>>>>> 
>>>>> $name = mysql_escape_string($_POST["name"]);
>>>>> 
>>>>> which would convert the offending character to &#8722; before entering
>>> it
>>>>> into the database. It's this encoding that is causing the problems since
>>>>> some scripts send out emails with this entry in their subject line which
>>>>> looks messy.
>>>>> 
>>>>> I've tried adding the following line after the previous line to help fix
>>>>> this issue, however, I just got another entry with the same problem.
>>>>> 
>>>>> preg_replace('/&#8722;/','-',$name);
>>>>> 
>>>>> Any suggestions on how others would fix this problem? I'd just like to
>>> fix
>>>>> it before the entry hits the database instead of creating fixes on the
>>> other
>>>>> end of things.
>>>>> 
>>>>> 
>>>>> Cheers,
>>>>> Michael
>>>>> --
>>>>> PHP General Mailing List (http://www.php.net/)
>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>> 
>>>> 
>>>> One option is to send an HTML email which would have the email reader
>>>> interpret that code correctly
>>>> 
>>>> Bastien
>>> 
>>> Another option would be to use mysql_real_escape_string and make sure
>>> that your code and the database are using utf-8. Then when the email
>>> is sent, make sure that uses utf-8 as well.
>>> 
>>> Regards
>>> Peter
>>> 
>>> 
>> Make sure the database connection is also utf8:
>> 
>> set names 'utf8';
>> 
>> Typically, you should keep everything in utf8 unless you have a very good
>> reason not to.
>> And as Peter mentioned, the proper way to escape MySQL inserts (that is, if
>> you're not already using a framework that does this competently) is
>> mysql_real_escape_string().
>> 
>> Michiel
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


--- End Message ---
--- Begin Message ---
That did it! Thanks!

Michael


On Apr 18, 2010, at 2:44 PM, Mari Masuda wrote:

> Maybe you could try to assign the return value of preg_replace to a variable 
> so you can use it later, like: 
> 
> $name = preg_replace('/&#8722;/','-',$name);
> 
> 
> On Apr 18, 2010, at 11:38 AM, Michael Stroh wrote:
> 
>> Thanks for the advice. I've changed the code to use 
>> mysql_real_escape_string. So now it is
>> 
>> $name = mysql_real_escape_string($name);
>> preg_replace('/&#8722;/','-',$name);
>> 
>> but it's still not replacing the &#8722; string. I've also changed the field 
>> in the database so that now it is using the collation utf8_general_ci. I've 
>> also tried
>> 
>> preg_replace('/−/','-',$name);
>> $name = mysql_real_escape_string($name);
>> preg_replace('/&#8722;/','-',$name);
>> 
>> and that also did not work. Any ideas?
>> 
>> Michael
>> 
>> 
>> 
>> On Apr 18, 2010, at 1:08 PM, Michiel Sikma wrote:
>> 
>>> On 18 April 2010 16:46, Peter Lind <[email protected]> wrote:
>>> 
>>>> On 18 April 2010 16:40, Phpster <[email protected]> wrote:
>>>>> 
>>>>> 
>>>>> On Apr 18, 2010, at 8:59 AM, Michael Stroh <[email protected]> wrote:
>>>>> 
>>>>>> I have this form that people use to add entries into a MySQL database.
>>>>>> Recently I've had some users insert − in their entries instead of -
>>>> which is
>>>>>> causing some issues with scripts down the line. I'd like to replace the
>>>> −
>>>>>> character with -.
>>>>>> 
>>>>>> Originally I had something like
>>>>>> 
>>>>>> $name = mysql_escape_string($_POST["name"]);
>>>>>> 
>>>>>> which would convert the offending character to &#8722; before entering
>>>> it
>>>>>> into the database. It's this encoding that is causing the problems since
>>>>>> some scripts send out emails with this entry in their subject line which
>>>>>> looks messy.
>>>>>> 
>>>>>> I've tried adding the following line after the previous line to help fix
>>>>>> this issue, however, I just got another entry with the same problem.
>>>>>> 
>>>>>> preg_replace('/&#8722;/','-',$name);
>>>>>> 
>>>>>> Any suggestions on how others would fix this problem? I'd just like to
>>>> fix
>>>>>> it before the entry hits the database instead of creating fixes on the
>>>> other
>>>>>> end of things.
>>>>>> 
>>>>>> 
>>>>>> Cheers,
>>>>>> Michael
>>>>>> --
>>>>>> PHP General Mailing List (http://www.php.net/)
>>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>>> 
>>>>> 
>>>>> One option is to send an HTML email which would have the email reader
>>>>> interpret that code correctly
>>>>> 
>>>>> Bastien
>>>> 
>>>> Another option would be to use mysql_real_escape_string and make sure
>>>> that your code and the database are using utf-8. Then when the email
>>>> is sent, make sure that uses utf-8 as well.
>>>> 
>>>> Regards
>>>> Peter
>>>> 
>>>> 
>>> Make sure the database connection is also utf8:
>>> 
>>> set names 'utf8';
>>> 
>>> Typically, you should keep everything in utf8 unless you have a very good
>>> reason not to.
>>> And as Peter mentioned, the proper way to escape MySQL inserts (that is, if
>>> you're not already using a framework that does this competently) is
>>> mysql_real_escape_string().
>>> 
>>> Michiel
>> 
>> 
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
> 


--- End Message ---
--- Begin Message ---
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



                                          
_________________________________________________________________
The New Busy is not the old busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_3

--- End Message ---
--- Begin Message ---
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";

Karl


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



                                        
_________________________________________________________________
The New Busy is not the old busy. Search, chat and e-mail from your inbox. http://www.windowslive.com/campaign/thenewbusy? ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_3

Karl DeSaulniers
Design Drumm
http://designdrumm.com


--- End Message ---
--- Begin Message ---
On 18 April 2010 02:08, Micky Hulse <[email protected]> wrote:

> Hi Michiel! Thanks for the help, I really appreciate it. :)
>
> > It depends. What's exactly do you want to prevent? It doesn't seem like a
> > ...<snip>...
> > include, say, additional HTML content, use file_get_contents() instead.
>
> Very good points. My goal was to write a plugin that would allow me to
> include some static HTML template file and get the <?php include...?>
> tags out of my CMS template. With that said, I think the only people
> using this code will be the developers of the templates, and not your
> standard user.
>
> I opted to use output buffering and readfile() for the speed, and
> include() would be an option if developers want to execute the code in
> the included file.
>
> Would file_get_contents() be faster than readfile and output
> buffering? Would using file_get_conents() and eval() be faster than
> using include() and output buffering?
>

I would prefer to use include() since it runs the code in the same context,
and using both file_get_contents() and eval() is a bit of a detour. eval()
also tends to be a lot slower than included code (though I'm not exactly
sure how slow).

I'm also not entirely sure whether file_get_contents() is slower than
readfile(), but file_get_contents() is useful if you want to do something
with your data rather than printing it right away.

Michiel

--- End Message ---
--- Begin Message ---
On Sun, Apr 18, 2010 at 10:23 AM, Michiel Sikma <[email protected]> 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.

Thanks again! Have an excellent day.

Cheers,
Micky

--- End Message ---
--- Begin Message ---
On 17 April 2010 13:03, Paulo-WORK <[email protected]> wrote:

> I have reached a solution for my problem with js.
> Following all the sugestions and using jquery turned out to be quite
> simple.
> using .hide( ) and .show( ) i am able to change the #div with Js enabled
> content and no js.
>
>

That's the best way to go. After all, the only real way to detect Javascript
is to *use* Javascript :)

Michiel

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

I posted this in the PHP-i18n list, however got no answer so trying
here).
We are making a blog platform (http://oire.org/) which is provided in
several languages (currently they are Russian, Ukrainian, and
English).
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!");
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?
Thanks a lot!

-- 
With best regards from Ukraine,
Andre
http://oire.org/ - The Fantasy blogs of Oire
Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @ 
jabber.org
Twitter: http://twitter.com/m_elensule


--- End Message ---
--- Begin Message ---
Andre Polykanine wrote:
Hi everyone,

I posted this in the PHP-i18n list, however got no answer so trying
here).
We are making a blog platform (http://oire.org/) which is provided in
several languages (currently they are Russian, Ukrainian, and
English).
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!");
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?
Thanks a lot!

A lot of systems just use conditional includes and a language array. So the following:

Some main file:
<?php

    $lang = tell_me_what_the_lang_code_is();
    require_once( "lang/messages.$lang.php" );

?>

And then in lang/messages.eng.php:
<?php

$messages['Welcome!']    = 'Welcome!';
$messages['login-label'] = 'Login:';
$messages['blah-blah']   = 'Blah blah';

?>

And then in lang/messages.fra.php you might have:
<?php

$messages['Welcome!']    = 'Bienvenu!';
$messages['login-label'] = 'Accès :';
$messages['blah-blah']   = 'Le blah blah';

?>

There's lots of variations on this also, but the above is a very common method.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--- End Message ---

Reply via email to