Understanding PHP: What is It & Why Do We Need It?

  • Context: PHP 
  • Thread starter Thread starter Dave Ritche
  • Start date Start date
  • Tags Tags
    Php
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
4 replies · 1K views
Dave Ritche
Messages
70
Reaction score
6
I'm really stuck at knowing about PHP..
What will happen without using PHP on your website?
I know it's server side but why we need it?to process forms?how PF uses PHP?
 
Physics news on Phys.org
If you have a static website that just displays things there is no need for PHP. If you have an interactive web site, then PHP is one of many tools you can use for code creation.
 
  • Like
Likes   Reactions: Silicon Waffle
PHP also integrates well with SQL, so it's useful if your website requires some database processing.
 
  • Like
Likes   Reactions: Silicon Waffle
My site isn't interactive and doesn't use any databases, but I nevertheless use PHP. First, it let's me adjust internal links automatically so that they work properly both on the server on my home computer, and on my public web hosting provider. This let's me develop and test new pages completely on my home computer before uploading them and making them public. Second, I can use an "include file" to insert code that's the same on each page, so if I ever need to change that stuff, I don't have to edit every single page.

In practice the pages look mostly like ordinary HTML and CSS, with a little bit of PHP code sprinkled in.
 
  • Like
Likes   Reactions: Silicon Waffle
Dave Ritche said:
...
I know it's server side but why we need it?to process forms?how PF uses PHP?
As people explained, it is mostly for interactive web sites. For instance, on PF you will have users and their roles, all of which are defined and stored also their credentials in one or more databases; so your posts, your profiles, etc can be edited, remembered and available for search by the system and other users.
To process a form, your client will send a request that contains his intent to the server. PHP will help you to extract the sent data and process/store them for particular purpose depending on your design and make a response after everything is successfully done. Today such a request-response model is re-formed via use of RESTful web-services.
 
  • Like
Likes   Reactions: Dave Ritche and Samy_A