October 22, 200917 yr Hey everyone, I wanted to get your opinion on something, which will potentially help me decide how I do website design in the future. I've spent over 6 years doing traditional HTML design, and I'm totally comfortable using it and creating good websites. I've just recently completed my first PHP website, which was a success with the client. It involved some minor database work (hence PHP), but the entire site was coded in PHP. By doing this, I've discovered some of the great features that coding in PHP gives you, like setting global variables, the PHP include function, and others. This has greatly helped speed up development of the site and made changes so much easier. So I was wondering... why not do all websites in PHP? Do you know of any downsides to constantly using PHP for web development? Future sites may or may not use databases, but even if they don't need a database, I'm thinking perhaps I should use PHP anyway because of how flexible it is for the reasons mentioned above. Are there any issues I should be aware of? Many thanks Darren
October 22, 200917 yr I'm just dipping my toe into php too, and I think it's brilliant I did my first if(i<=4) statement and used dynamic links using index.php?id=. Probably a bit too excited by such a small thing lol. I guess if you use it a lot it's a drain on your server, and takes a bit longer to process, because its parsing the php then sending it back as html etc. Best bet is to only use it when you really need it. And know when to use single and double quotes. Double quotes get parsed too don't they?
October 22, 200917 yr Author Double quotes get parsed too don't they? I presume so. Is there a difference between single and double quotes? Thanks for the feedback mate, cheers.
October 22, 200917 yr I presume so. Is there a difference between single and double quotes? Thanks for the feedback mate, cheers. Yes, single quotes get interpreted as literal strings, double quotes get parsed and processed as php as in: echo '$variable' will print $variable echo "$variable" will print whatever you set the variable as. The first is processed quicker. I think?? ...just looked it up... http://v1.jeroenmulder.com/weblog/2005/04/php_single_and_double_quotes.php
October 22, 200917 yr Is there a difference between single and double quotes? Of course! <?php echo '<a href="http://www.example.com">This link breaks if you do not pay attention to single & double quotes</a>'; ?>
October 22, 200917 yr Author Yes, single quotes get interpreted as literal strings, double quotes get parsed and processed as php as in: echo '$variable' will print $variable echo "$variable" will print whatever you set the variable as. The first is processed quicker. I think?? ...just looked it up... http://v1.jeroenmulder.com/weblog/2005/04/php_single_and_double_quotes.php Thanks for that. Not sure how I didn't notice this before, I guess I've always picked the right one because this was never a problem. But in your opinion even if I use simple PHP includes (say for the header.php and footer.php) it will be slightly slower to load than the HTML full page?
October 22, 200917 yr Author Yes, single quotes get interpreted as literal strings, double quotes get parsed and processed as php as in: echo '$variable' will print $variable echo "$variable" will print whatever you set the variable as. I've just had a play and yes I can see now what you mean. I store a variable called $tel1 as an 0800 number, and calling it with ' only produces $tel1. Calling it with quotes " does produce the 0800, but I can also produce the 0800 number by not using either " or '. Is there any particular reason why I should use " when not using it will do? Darren
October 22, 200917 yr I dont particularly see the point in using php over html if you dont need to, i.e, it is not going to be a 'dynamic' website. I dont really see how you can code a website with just php, other than to echo out alot of html?? which is kind of convoluted? If its just a static site, I think using php is a bit unneccessary, and if its a dynamic site then it makes sense to use it. However, I did come accross a point when making a site that made a good argument for using php file format over html. I had an html static site, and on one page there was an accordion spry thing, and it was filled with loads of different pictures which took ages to load when called on my browser. But, I encased the whole lot in php tags, changed the file format, and hey presto, the page loaded almost instantly from there on in. I had some other quite content heavy html pages, and just encasing the whole lot in php tags and renaming the file so it would be parsed before being sent to the browser cut out all that nasty loading glitching picture popping-ness you sometimes get.
October 23, 200917 yr I use PHP in just about every website I code. When it has a longer URL, I'll store it as a PHP variable and echo it where I need to. That also makes it easier to move the site (this really helps when moving from localhost to the live site). Then of course I use the include() function to include a global header and footer on each page.
October 23, 200917 yr Author I use PHP in just about every website I code. When it has a longer URL, I'll store it as a PHP variable and echo it where I need to. That also makes it easier to move the site (this really helps when moving from localhost to the live site). Then of course I use the include() function to include a global header and footer on each page. The include function is one of the great upsides I've found using PHP, and now going back to HTML seems like a step in the wrong direction! Assuming I have no database connections, is it really going to slow down the performance of my PHP website if I just use includes and variables?
October 23, 200917 yr I tend to add this inside my .htaccess file RemoveHandler .html .htm AddType application/x-httpd-php .php .htm .html It allows me to process php within a html document.
October 23, 200917 yr I tend to add this inside my .htaccess file RemoveHandler .html .htm AddType application/x-httpd-php .php .htm .html It allows me to process php within a html document. omg you can do that?
October 23, 200917 yr Author It allows me to process php within a html document. I don't understand what that means? I thought PHP code in a HTML document, e.g. <?php echo ('Whatever'); ?> was displayed as HTML but the page kept the .php file format?
Create an account or sign in to comment