The Coding Languages of WordPress – PHP

By Reuben Walker, 22 May, 2022
Graphic of PHP code used in WordPress

PHP

Illustration of man walking by a large monitor with code displayed.

Contents

  • What is PHP?
  • What does PHP do?
  • PHP Frameworks
  • PHP Resources
  • This is the third in a series of posts looking at the coding languages that form a WordPress site. It features a quick overview of how PHP works on you site.


    In general, when coding a site for WordPress, you should prioritize languages in this order. First, accomplish anything you can with HTML, the subject of the first article in the series. Then with CSS, the subject of the second article, then PHP, the subject of this article, then Javascript, the subject of the fourth article. Doing so will minimize the size of your webpages, speed up loading, and help your SEO and user experience.

    PHP and Javascript code is more likely to be updated by developers once a site is live compared to HTML and CSS, which end users may also edit.

    While HTML provides your site’s meaning and structure and CSS provides its aesthetics, PHP, along with Javascript, provides interactivity and functionality. They are the frontend languages used in WordPress. In other words, they control what is seen in the browser.

    What is PHP?

    Created in 1994 by Rasmus Lerdorf, PHP is now a recursive acronym for PHP: Hypertext Preprocessor. A popular open-source general-purpose scripting language, PHP usually focuses on server-side scripting.

    It is a very flexible tool that can be used for good (WordPress) ;) or evil (Facebook) :( . Other large users include Yahoo, Wikipedia, Tumblr, MailChimp, Flickr, Digg, and Baidu.

    It is commonly used with a MySQL database, which is the case with WordPress. A page/post is a combination of PHP, HTML, Javascript, and MySQL statements laid out with CSS. PHP files can contain all of these but only output HTML.

    Image courtesy of visual.ly. Select the image to see the entire infographic.

    Sections of your WordPress pages and posts are stored in php frontend template files in your theme. These include:

    • The Header
    • The Footer
    • The Sidebar
    • The Loop - "Body Pages"

    As seen in the image above, the WordPress Loop may contain index.php (homepage), archive.php, page.php, single.php, comment.php, or search.php files.

    Much of your site's functionality is coded in the functions.php file. Although more modern programming practices break it up into multiple modular components.

    The backend of WordPress (admin area) is also built with PHP.

    PHP Logo

    PHP: Hypertext Preprocessor

    What makes PHP different from something like client-side JavaScript is that the code is executed on the server, generating HTML, which is then sent to the client, usually a browser. The browser receives the results of running PHP scripting but doesn't see the underlying code.

    Like other scripting languages, PHP has variables, data types, operators, values, parameters, expressions, if...else...elseif statements, switch statements, loops, functions, arrays, scopes, and superglobals.

    What does PHP do?

    • PHP generates dynamic content
    • PHP creates, opens, reads, writes, deletes, and closes files
    • PHP stores form data
    • PHP adds, deletes, and modifies data in your database
    • PHP encrypts that data
    • PHP sends and receives cookies
    • PHP controls user-access
    • and much more

    The current edition of PHP is PHP8. The latest update and evolving CSS are doing more of the work Javascript has historically done.

    PHP Frameworks

    WordPress is not a PHP framework but a CMS (content management system) that uses PHP code. PHP frameworks can also be used to build things other than CMSs and websites.

    To quote Wikipedia frameworks are "an abstraction in which software providing generic functionality can be selectively changed by additional user-written code, thus providing application-specific software.

    It provides a standard way to build and deploy applications and is a universal, reusable software environment that provides particular functionality as part of a larger software platform...

    Software frameworks may include support programs, compilers, code libraries, toolsets, and application programming interfaces (APIs) that bring together all the different components to enable the development of a project or system."

    A PHP framework provides the core infrastructure for turning an incoming HTTP request into an HTTP response.

    PHP frameworks include:

    • Laravel
    • Cake
    • FuelPHP
    • Zend
    • Symfony
    • CodeIgniter
    • Phalcon

    Wrapping Up

    As you have seen, PHP is a much more complicated language than HTML and (to a lesser degree) CSS. It is the primary coding language that makes WordPress work. Like CSS, many books and websites cover extensive details of PHP. Since this is only an introductory article, below are some useful resources for you to explore.

    PHP Resources

    Tags

    Authored by

     

    Reuben Walker toasting you


    Do you want more news on PHP and CMS development, cybersecurity, and more? Our sister site, Symfony Station has a weekly news roundup.

    📩

    Join our list  

    * indicates required
     
     
     
     
     
     
    Anything Else