PHP Advantages

johnnieblue

macrumors newbie
Original poster
Jul 12, 2011
22
0
Hey Everyone,

I was just wondering about the advantages of coding with PHP, what can you do with it that you can't do with HTML and CSS?

I'm not sure i fully understand exactly what PHP is used for. I researched a bit but i still can't tell if it's something i want to spend my time learning.

Thoughts?
 

englishman

macrumors 6502a
Nov 6, 2006
723
8
If you look at any website that isn't just a baby one it will be using PHP or another programming language.

Take this site.

It would be be impossible for any army of web editors to create pages from everyone's contributions.

People's contributions are stored in a database and then the threads are created on the fly from mixing the data in the database and PHP and HTML to create these pages you see.

So the word advantage is the wrong way of looking at it. There is no other way.
 
Comment

johnnieblue

macrumors newbie
Original poster
Jul 12, 2011
22
0
I know...

Like i said, I have researched it a bit but what i was looking for by posting was someone who uses PHP that may have some information regarding it's practical uses.

(this post was in reply to a message that has since been deleted)
 
Last edited:
Comment

Dunmail

macrumors regular
Mar 27, 2009
216
0
Skipton, UK
Hey Everyone,

I was just wondering about the advantages of coding with PHP, what can you do with it that you can't do with HTML and CSS?

I'm not sure i fully understand exactly what PHP is used for. I researched a bit but i still can't tell if it's something i want to spend my time learning.

Thoughts?
PHP is for server side programming - so it's used for things like database access and content management systems - whereas HTML, CSS and JavaScript are what your browser can understand.

At a simple level you might have a line in all your PHP files like

PHP:
include("menu.inc.php");
This will pull in the named file and write the code for your menu in to the HTML being sent to your browser. So if you wish to change the menu for your site, all you have to do is modify menu.inc.php, upload it to your server and the site is modified.

You could also do browser sniffing on the server side so when a request for a page comes in you check the browser/OS/device and provide a suitable CSS file (for example). Thus you could serve up an optimised page for smartphones from the same basic source.

HTH
 
Comment

bpaluzzi

macrumors 6502a
Sep 2, 2010
919
1
London
Hey Everyone,

I was just wondering about the advantages of coding with PHP, what can you do with it that you can't do with HTML and CSS?

I'm not sure i fully understand exactly what PHP is used for. I researched a bit but i still can't tell if it's something i want to spend my time learning.

Thoughts?

It's not an either/or situation. HTML/CSS/Javascript are the client-side technologies. PHP/Rails/Python/.NET are server-side languages (edit: thanks englishman), and they do the heavy-lifting and data access. The output of those languages is HTML, which is then sent to the browser and rendered.
 
Last edited:
Comment

englishman

macrumors 6502a
Nov 6, 2006
723
8
It's not an either/or situation. HTML/CSS/Javascript are the client-side technologies. PHP/Rails/Python/.NET are client-side languages, and they do the heavy-lifting and data access. The output of those languages is HTML, which is then sent to the browser and rendered.
Ooops you mean server side
 
Comment

govinthmani

macrumors newbie
Jul 23, 2011
1
0
Hi..here i provides some advantages of PHP...

1. Robust Support for Object-Oriented Programming
2. A Completely Rewritten MySQL Extension
3. A Suite of Interoperable XML Tools
4. Cleaner Error Handling with Exceptions
5. A First-Class SOAP Implementation
 
Comment

englishman

macrumors 6502a
Nov 6, 2006
723
8
Worth noting some disadvantages if thinking of a complete solution.

Unlike .NET or J2EE, PHP is not a complete Enterprise solution to eg mobile phone programming/desktop programming.
 
Comment

haydn!

macrumors 65816
Nov 10, 2008
1,013
963
UK
Even in basic web design it has it's usefulness.

The most popular uses (in basic design) are to use it to repeat certain pieces of html/css so that you don't have to write the same thing over and over and more importantly you can make side wide changes to things like your header, navigation etc by only having to edit one file.

For example, keep you header and footers in separate files then just use PHP to fetch the code to add it to the start/end of each individual page.
 
Comment

Ronald Williams

macrumors member
Jul 11, 2011
38
0
php or any other programming language makes a website functional and it enables to handle all the data between the users and the servers, to implement complex logics to execute even more complex methods and functions. Php itself is easy to learn so if you are interested then you can get started with programming in php in very less time.
 
Comment

wrldwzrd89

macrumors G5
Jun 6, 2003
12,107
75
Solon, OH
I'm using PHP on my site purely for the include feature, because it makes site development so much simpler. I do wonder, though, if there's a different/better way to include stuff.
 
Comment

bpaluzzi

macrumors 6502a
Sep 2, 2010
919
1
London
Thanks for bringing this to my attention - I forgot that generic server side includes existed, and thus didn't bother to check if my web host supports them (which it does).
Wicked! SSI is great for that kind of stuff -- don't need to worry about the overhead of PHP. Just remember to set up your index file as index.shtml, or visitors will either get a directory listing or an unauthorized (got burned on that for about a week a long time ago) :)

b
 
Comment
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.