php-general Digest 2 Jan 2011 16:52:44 -0000 Issue 7112
php-general Digest 2 Jan 2011 16:52:44 - Issue 7112 Topics (messages 310442 through 310449): Re: Regex for ... genealogical names 310442 by: Al Newbie Question 310443 by: Adolfo Olivera 310444 by: Joshua Kehn 310445 by: David Robley 310446 by: Joshua Kehn 310447 by: Adolfo Olivera 310448 by: Joshua Kehn 310449 by: admin.buskirkgraphics.com 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 -- ---BeginMessage--- On 1/1/2011 4:46 AM, Lester Caine wrote: JohnDoeSMITH' or 'John Doe SMITH' Try this. not tested. First, which adds spaces as needed. e.g. JohnDoeSMITH 'John Doe SMITH' $newName=preg_replace(%(?=[a-z])([A-Z]), $1, $name);//Cap following low case, add space before it Next, alphas following a cap, lower case them function lowCase($matches){return strtolower($matches[1]);} $newName= preg_replace_callback(%(?=[A-Z])([A-Z])%, lowCase', $newName); Sorry don't have time today to test; but, this should get you started. ---End Message--- ---BeginMessage--- Hi, I'm new for php. Just trying to get my hello world going on godaddy hosting. Can't getting to work. I think sintax it's ok. I was understanding that my shared hosting plan had php installed. Any suggestions. Thanks, Happy 2011!! PS: Please, feel free to educate me on how to address the mailing list, since again, I'm new to php and not a regular user of mailing lists, ---End Message--- ---BeginMessage--- On Jan 1, 2011, at 7:36 PM, Adolfo Olivera wrote: Hi, I'm new for php. Just trying to get my hello world going on godaddy hosting. Can't getting to work. I think sintax it's ok. I was understanding that my shared hosting plan had php installed. Any suggestions. Thanks, Happy 2011!! PS: Please, feel free to educate me on how to address the mailing list, since again, I'm new to php and not a regular user of mailing lists, Can you post the code that you are using? It should look something like the following: ?php echo Hello World!; ? Regards, -Josh Joshua Kehn | josh.k...@gmail.com http://joshuakehn.com ---End Message--- ---BeginMessage--- Joshua Kehn wrote: On Jan 1, 2011, at 7:36 PM, Adolfo Olivera wrote: Hi, I'm new for php. Just trying to get my hello world going on godaddy hosting. Can't getting to work. I think sintax it's ok. I was understanding that my shared hosting plan had php installed. Any suggestions. Thanks, Happy 2011!! PS: Please, feel free to educate me on how to address the mailing list, since again, I'm new to php and not a regular user of mailing lists, Can you post the code that you are using? It should look something like the following: ?php echo Hello World!; ? And normally would need to be saved as a .php file so the contents will be handled by php. Cheers -- David Robley A fool and his money are my two favourite people. Today is Boomtime, the 2nd day of Chaos in the YOLD 3177. ---End Message--- ---BeginMessage--- On Jan 1, 2011, at 7:50 PM, David Robley wrote: And normally would need to be saved as a .php file so the contents will be handled by php. Cheers -- David Robley A fool and his money are my two favourite people. Today is Boomtime, the 2nd day of Chaos in the YOLD 3177. Save the code as hello.php. Copy it to your root web directory (should be the base directory or something called public_html / www when you FTP in) and access it from youdomain.com/hello.php Regards, -Josh Joshua Kehn | josh.k...@gmail.com http://joshuakehn.com ---End Message--- ---BeginMessage--- Sorry, here is the code. The .php extension is a requirement? Can't it b embedded on a .html file? !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns= http://www.w3.org/1999/xhtml; head meta http-equiv=Content-Type content=text/html; charset=utf-8 / titleUntitled Document/title /head body ?php $a = hello; $hello =Hello Everyone; echo $a; echo $hello; ? /body /html On Sat, Jan 1, 2011 at 9:55 PM, Joshua Kehn josh.k...@gmail.com wrote: On Jan 1, 2011, at 7:50 PM, David Robley wrote: And normally would need to be saved as a .php file so the contents will be handled by php. Cheers -- David Robley A fool and his money are my two favourite people. Today is Boomtime, the 2nd day of Chaos in the YOLD 3177. Save the code as hello.php. Copy it to your root web directory (should be the base directory or something called public_html / www when you FTP in) and access it from youdomain.com/hello.php Regards, -Josh
RE: [PHP] Newbie Question
Add this to your .htaccess file and HTML files will be handled like PHP files allowing you put PHP in HTML files. AddType application/x-httpd-php .html Richard L. Buskirk -Original Message- From: Adolfo Olivera [mailto:olivera.ado...@gmail.com] Sent: Saturday, January 01, 2011 8:38 PM To: Joshua Kehn Cc: robl...@aapt.net.au; php-general@lists.php.net Subject: Re: [PHP] Newbie Question Sorry, here is the code. The .php extension is a requirement? Can't it b embedded on a .html file? !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns= http://www.w3.org/1999/xhtml; head meta http-equiv=Content-Type content=text/html; charset=utf-8 / titleUntitled Document/title /head body ?php $a = hello; $hello =Hello Everyone; echo $a; echo $hello; ? /body /html On Sat, Jan 1, 2011 at 9:55 PM, Joshua Kehn josh.k...@gmail.com wrote: On Jan 1, 2011, at 7:50 PM, David Robley wrote: And normally would need to be saved as a .php file so the contents will be handled by php. Cheers -- David Robley A fool and his money are my two favourite people. Today is Boomtime, the 2nd day of Chaos in the YOLD 3177. Save the code as hello.php. Copy it to your root web directory (should be the base directory or something called public_html / www when you FTP in) and access it from youdomain.com/hello.php Regards, -Josh Joshua Kehn | josh.k...@gmail.com http://joshuakehn.com -- Adolfo Olivera 15-3429-9743 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Newbie Question
On Sun, 2011-01-02 at 11:48 -0500, ad...@buskirkgraphics.com wrote: Add this to your .htaccess file and HTML files will be handled like PHP files allowing you put PHP in HTML files. AddType application/x-httpd-php .html Richard L. Buskirk -Original Message- From: Adolfo Olivera [mailto:olivera.ado...@gmail.com] Sent: Saturday, January 01, 2011 8:38 PM To: Joshua Kehn Cc: robl...@aapt.net.au; php-general@lists.php.net Subject: Re: [PHP] Newbie Question Sorry, here is the code. The .php extension is a requirement? Can't it b embedded on a .html file? !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns= http://www.w3.org/1999/xhtml; head meta http-equiv=Content-Type content=text/html; charset=utf-8 / titleUntitled Document/title /head body ?php $a = hello; $hello =Hello Everyone; echo $a; echo $hello; ? /body /html On Sat, Jan 1, 2011 at 9:55 PM, Joshua Kehn josh.k...@gmail.com wrote: On Jan 1, 2011, at 7:50 PM, David Robley wrote: And normally would need to be saved as a .php file so the contents will be handled by php. Cheers -- David Robley A fool and his money are my two favourite people. Today is Boomtime, the 2nd day of Chaos in the YOLD 3177. Save the code as hello.php. Copy it to your root web directory (should be the base directory or something called public_html / www when you FTP in) and access it from youdomain.com/hello.php Regards, -Josh Joshua Kehn | josh.k...@gmail.com http://joshuakehn.com -- Adolfo Olivera 15-3429-9743 It's really best not to think about embedding PHP in an HTML file, as that isn't really how it works and it just encourages bad practices. HTML is embedded inside PHP files, not the other way around. The PHP parser interprets all the PHP code and creates the necessary output, and passes that output along with any HTML to the web server to then deliver to the client (browser). If you embedded PHP inside HTML files, the web server would have to call up the PHP parser every time you broke in and out of PHP tags, which wouldn't do at all! I wouldn't recommend having .html parsed as PHP though, as it will slow down your website/application unnecessarily for any .html files that contain no PHP code, as PHP still has to parse the file for any code, even if there is none. Leave .html files for static pages that you produce with a PHP app for example, or use MOD_REWRITE to reference PHP scripts when certain .html files are requested by the browser, as this can be a whole lot more specific and selective and won't introduce problems later on. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Newbie Question
On Jan 2, 2011, at 11:48 AM, ad...@buskirkgraphics.com wrote: Add this to your .htaccess file and HTML files will be handled like PHP files allowing you put PHP in HTML files. AddType application/x-httpd-php .html Richard L. Buskirk I would not recommend this approach, some perfectly valid reasons given by Ash. It's the wrong mindset to have. Regards, -Josh Joshua Kehn | josh.k...@gmail.com http://joshuakehn.com
RE: [PHP] Newbie Question
The question was The .php extension is a requirement? The answer is no. While me and Ash may completely disagree on the php parser, the simple answer is there are many ways around running a non .php extension file in php. mod_rewrite rules in .htaccess files are interpreted for each request and CAN slow down things if your traffic is high. Having said that, mod_rewrite in httpd.conf is faster because it is compiled at server restart and it is native to the server. As a beginner, I completely agree with ash on bad practice rule of thumb. You will simply rewrite the html file later on wishing you had never did the hack to make it function. Richard L. Buskirk -Original Message- From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] Sent: Sunday, January 02, 2011 12:16 PM To: ad...@buskirkgraphics.com Cc: 'Adolfo Olivera'; 'Joshua Kehn'; robl...@aapt.net.au; php-general@lists.php.net Subject: RE: [PHP] Newbie Question On Sun, 2011-01-02 at 11:48 -0500, ad...@buskirkgraphics.com wrote: Add this to your .htaccess file and HTML files will be handled like PHP files allowing you put PHP in HTML files. AddType application/x-httpd-php .html Richard L. Buskirk -Original Message- From: Adolfo Olivera [mailto:olivera.ado...@gmail.com] Sent: Saturday, January 01, 2011 8:38 PM To: Joshua Kehn Cc: robl...@aapt.net.au; php-general@lists.php.net Subject: Re: [PHP] Newbie Question Sorry, here is the code. The .php extension is a requirement? Can't it b embedded on a .html file? !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns= http://www.w3.org/1999/xhtml; head meta http-equiv=Content-Type content=text/html; charset=utf-8 / titleUntitled Document/title /head body ?php $a = hello; $hello =Hello Everyone; echo $a; echo $hello; ? /body /html On Sat, Jan 1, 2011 at 9:55 PM, Joshua Kehn josh.k...@gmail.com wrote: On Jan 1, 2011, at 7:50 PM, David Robley wrote: And normally would need to be saved as a .php file so the contents will be handled by php. Cheers -- David Robley A fool and his money are my two favourite people. Today is Boomtime, the 2nd day of Chaos in the YOLD 3177. Save the code as hello.php. Copy it to your root web directory (should be the base directory or something called public_html / www when you FTP in) and access it from youdomain.com/hello.php Regards, -Josh Joshua Kehn | josh.k...@gmail.com http://joshuakehn.com -- Adolfo Olivera 15-3429-9743 It's really best not to think about embedding PHP in an HTML file, as that isn't really how it works and it just encourages bad practices. HTML is embedded inside PHP files, not the other way around. The PHP parser interprets all the PHP code and creates the necessary output, and passes that output along with any HTML to the web server to then deliver to the client (browser). If you embedded PHP inside HTML files, the web server would have to call up the PHP parser every time you broke in and out of PHP tags, which wouldn't do at all! I wouldn't recommend having .html parsed as PHP though, as it will slow down your website/application unnecessarily for any .html files that contain no PHP code, as PHP still has to parse the file for any code, even if there is none. Leave .html files for static pages that you produce with a PHP app for example, or use MOD_REWRITE to reference PHP scripts when certain .html files are requested by the browser, as this can be a whole lot more specific and selective and won't introduce problems later on. Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie Question
On Jan 2, 2011, at 12:50 PM, ad...@buskirkgraphics.com wrote: The question was The .php extension is a requirement? The answer is no. While me and Ash may completely disagree on the php parser, the simple answer is there are many ways around running a non .php extension file in php. mod_rewrite rules in .htaccess files are interpreted for each request and CAN slow down things if your traffic is high. Having said that, mod_rewrite in httpd.conf is faster because it is compiled at server restart and it is native to the server. As a beginner, I completely agree with ash on bad practice rule of thumb. You will simply rewrite the html file later on wishing you had never did the hack to make it function. Richard L. Buskirk Sorry, here is the code. The .php extension is a requirement? Can't it b embedded on a .html file? _This_ question when asked from a beginner requires a non-confusing answer of yes. Can't it be embedded on a .html file? PHP is always embedded alongside HTML code within ?php ? tags. It's not embedded inside a .html file as the extension should indicate the file type. Adding a mod_rewrite rule (as you suggest) can lead to confusion later on in development. At the very least you'll look stupid re-asking Can't it be embedded... Regards, -Josh Joshua Kehn | josh.k...@gmail.com http://joshuakehn.com
Re: [PHP] Newbie Question
On Sun, Jan 2, 2011 at 12:16 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Sun, 2011-01-02 at 11:48 -0500, ad...@buskirkgraphics.com wrote: Add this to your .htaccess file and HTML files will be handled like PHP files allowing you put PHP in HTML files. AddType application/x-httpd-php .html I wouldn't recommend having .html parsed as PHP though, as it will slow down your website/application unnecessarily for any .html files that contain no PHP code, as PHP still has to parse the file for any code, even if there is none. Leave .html files for static pages that you produce with a PHP app for example, or use MOD_REWRITE to reference PHP scripts when certain .html files are requested by the browser, as this can be a whole lot more specific and selective and won't introduce problems later on. I tend to disagree with Ashley on this topic. For many websites, I'll start out making all pages .php, even if they don't require PHP at the moment. That's for a couple reasons. 1) A few years back, there was certainly a significant performance advantage to keeping essentially static pages html. However, in my current benchmarking (using both siege and ab on my Ubuntu servers using apache with mod_php), if I use a cache such as APC and a well-configured apache server, PHP tends to perform just as well (or sometimes even better) than the html version. Rasmus has demonstrated similar performance results: http://talks.php.net/show/froscon08/24 2) I don't want to have to change urls site-wide and set up redirects from the old url whenever a page requires adding dynamic capabilities. By making all pages PHP right from the beginning, adding dynamic capabilities is a snap as I just add the functionality. Adam -- Nephtali: A simple, flexible, fast, and security-focused PHP framework http://nephtaliproject.com
Re: [PHP] Newbie Question
On Jan 2, 2011, at 1:17 PM, Adam Richardson wrote: I tend to disagree with Ashley on this topic. For many websites, I'll start out making all pages .php, even if they don't require PHP at the moment. That's for a couple reasons. 1) A few years back, there was certainly a significant performance advantage to keeping essentially static pages html. However, in my current benchmarking (using both siege and ab on my Ubuntu servers using apache with mod_php), if I use a cache such as APC and a well-configured apache server, PHP tends to perform just as well (or sometimes even better) than the html version. Rasmus has demonstrated similar performance results: http://talks.php.net/show/froscon08/24 2) I don't want to have to change urls site-wide and set up redirects from the old url whenever a page requires adding dynamic capabilities. By making all pages PHP right from the beginning, adding dynamic capabilities is a snap as I just add the functionality. Adam I agree starting with all .php files is good practice for basic sites. I recommend for applications and bigger then basic project using a decent framework or main routing file to handle routes for you, instead of requiring you to manually adjust them if something changes. Regards, -Josh Joshua Kehn | josh.k...@gmail.com http://joshuakehn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie Question
Thanks for the replies. I'll just put a php on all my html containing php. A little of topic. Wich IDE are you guys using. I'm sort of in a catch twenty two here. I been alternating vim and dreamweaver. I'm trying to go 100% open source, but I really find dreamweaver easier to use so far. El ene 2, 2011 3:25 p.m., Joshua Kehn josh.k...@gmail.com escribió: On Jan 2, 2011, at 1:17 PM, Adam Richardson wrote: I tend to disagree with Ashley on this topic... I agree starting with all .php files is good practice for basic sites. I recommend for applications and bigger then basic project using a decent framework or main routing file to handle routes for you, instead of requiring you to manually adjust them if something changes. Regards, -Josh Joshua Kehn | josh.k...@gmail.com http://joshu... PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie Question
On Jan 2, 2011, at 5:56 PM, Adolfo Olivera wrote: Thanks for the replies. I'll just put a php on all my html containing php. A little of topic. Wich IDE are you guys using. I'm sort of in a catch twenty two here. I been alternating vim and dreamweaver. I'm trying to go 100% open source, but I really find dreamweaver easier to use so far. I use VIM and TextMate exclusively. Regards, -Josh Joshua Kehn | josh.k...@gmail.com http://joshuakehn.com
Re: [PHP] Newbie Question
On Sunday, January 02, 2011 4:56:28 pm Adolfo Olivera wrote: Thanks for the replies. I'll just put a php on all my html containing php. A little of topic. Wich IDE are you guys using. I'm sort of in a catch twenty two here. I been alternating vim and dreamweaver. I'm trying to go 100% open source, but I really find dreamweaver easier to use so far. I bounce between NetBeans and Eclipse, depending on which currently sucks less. I have yet to find a PHP IDE that doesn't suck; it's just degrees of suckage. :-) --Larry Garfield -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie Question
On Sunday, January 02, 2011 08:43:51 pm Larry Garfield wrote: On Sunday, January 02, 2011 4:56:28 pm Adolfo Olivera wrote: Thanks for the replies. I'll just put a php on all my html containing php. A little of topic. Wich IDE are you guys using. I'm sort of in a catch twenty two here. I been alternating vim and dreamweaver. I'm trying to go 100% open source, but I really find dreamweaver easier to use so far. I bounce between NetBeans and Eclipse, depending on which currently sucks less. I have yet to find a PHP IDE that doesn't suck; it's just degrees of suckage. :-) I use Kate. It doesn't suck at all because it doesn't try to do the coding for you :-) -- Blessings David M. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php