PHP Advantages

Discussion in 'Web Design and Development' started by johnnieblue, Jul 16, 2011.

  1. johnnieblue macrumors newbie

    johnnieblue

    Joined:
    Jul 12, 2011
    #1
    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?
     
  2. englishman macrumors 6502a

    englishman

    Joined:
    Nov 6, 2006
    #2
    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.
     
  3. johnnieblue, Jul 16, 2011
    Last edited: Jul 16, 2011

    johnnieblue thread starter macrumors newbie

    johnnieblue

    Joined:
    Jul 12, 2011
    #3
    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)
     
  4. Dunmail macrumors regular

    Joined:
    Mar 27, 2009
    Location:
    Skipton, UK
    #4
    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
     
  5. bpaluzzi, Jul 16, 2011
    Last edited: Jul 16, 2011

    bpaluzzi macrumors 6502a

    bpaluzzi

    Joined:
    Sep 2, 2010
    Location:
    London
    #5

    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.
     
  6. englishman macrumors 6502a

    englishman

    Joined:
    Nov 6, 2006
    #6
    Ooops you mean server side
     
  7. johnnieblue thread starter macrumors newbie

    johnnieblue

    Joined:
    Jul 12, 2011
  8. govinthmani macrumors newbie

    Joined:
    Jul 23, 2011
    #8
    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
     
  9. englishman macrumors 6502a

    englishman

    Joined:
    Nov 6, 2006
    #9
    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.
     
  10. haydn! macrumors 6502a

    Joined:
    Nov 10, 2008
    Location:
    UK
    #10
    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.
     
  11. Ronald Williams macrumors member

    Joined:
    Jul 11, 2011
    #11
    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.
     
  12. wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #12
    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.
     
  13. bpaluzzi macrumors 6502a

    bpaluzzi

    Joined:
    Sep 2, 2010
    Location:
    London
    #13
    If you're just using it for includes, most hosting companies / servers that support PHP also support generic server side includes:
    http://en.wikipedia.org/wiki/Server_Side_Includes
     
  14. wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #14
    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).
     
  15. bpaluzzi macrumors 6502a

    bpaluzzi

    Joined:
    Sep 2, 2010
    Location:
    London
    #15
    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
     

Share This Page