Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

Introduction To PHP

****This is a work in progress****

This thread is a simple introduction to PHP, as it contains basic information of PHP along with the capabilities of PHP. Along with some pointers and other valuable resources to get you started with the great language. This thread also contains some example open source applications written in PHP, so you can try it out yourself.

Table of Contents:
  1. Basics of PHP
    • What is PHP?
    • Capabilities of PHP
    • PHP a Server-Side
    • PHP as CLI
    • PHP as a GUI Application

  2. How to Learn PHP
  3. Setting up a PHP development environment
  4. PHP Open Source Applications
    • Content Management Systems
    • Frameworks
    • PHP Libraries

  5. PHP Resources & Tutorials
  6. Final Remarks
1. Basics of PHP
What is PHP?
  • PHP is a programming language that is very easy to learn, and is capable of doing a wide variety of tasks, such as handling user input, communicating to a database to display content, develop dynamic websites, and more. PHP is commonly used to operate the server side, which is the backend that powers many websites and web applications. However, PHP can also be used with the command line, and you can even create GUI applications with PHP.

    PHP has many similarities of other programming languages, if you have experience with other languages you might find PHP even easier to learn, as it has common features of other languages, such as OOP (classes), variables, conditions and statements, functions, etc.

    In order to use PHP for your website, you are required to have the PHP engine installed on your system in order to execute the code. You cannot open PHP files into your web browser, as browsers are not capable of executing PHP code, thus you will need to have a webserver such as Apache that uses the PHP engine when a visitor requests a file powered by PHP.

    Due to the popularity of PHP, many website hosting providers have PHP installed on their servers.

Capabilities of PHP
  • PHP is a very powerful language that offers many features for developers. PHP offers many features such as communicating with a database, communicating with a mail server, managing files, template engine, and more.

    PHP is very fast, and is cross-platform. You can develop a PHP application on a Windows-based operating system, and publish it to Unix and Unix-like distributions.

    PHP has many extensions that can be used to improve the language significantly, including: image manipulation and creation, SMTP and IMAP support, sockets, CURL, file compression. There are also many database drivers for PHP that can be installed, including but not limited to: MySQL, MS SQL, SQLite, PostgreSQL, ODBC and MongoDB. If you have knowledge of C/C++, you can create your own PHP extensions, or with the help of third-party software, you can write PHP extensions with PHP code!

    PHP is a powerful and open language. You are not restricted to a single form of programming; you have the ability to program in PHP using the procedural way, or object-oriented way. Procedural programming, is a form of programming that is carried out in routines, it works on a step-by-step basis to carry out operations. Object-oriented programming is different, as everything is carried out using objects. Objects allow you to store properties, and can have methods to carry out operations, with objects you can easily re-use and extend code. For example, a car has different properties about it (colour, max speed, horse power, materials used, etc) and has different methods to do certain things. With objects, you can easily extend and override properties, for example, you can have a base object for a person, but you can change the name, age, height, gender and personality of that person.

PHP as Server-Side
  • PHP can be used to power the backend (or server side) of a website. The PHP code will be executed by the server that operates the website, the final result of the script will be returned to the visitor and will be rendered by the visitor’s web browser. Unlike HTML, the PHP code will never be sent to the visitor. The PHP code is executed by the PHP interpreter that is installed on the webserver, the final result will then be sent to the visitor’s browser, and will be rendered. For example, consider the following PHP script:

    PHP Code

    <?php
        
    echo "<strong>" . (6 + 4 - 2) * 2 . "</strong>";
    ?>

    The above script, will be executed by the PHP engine, it will solve the mathematical equation, and return the result (16) surrounded by HTML strong tags, to the visitor. The visitor’s browser will then render it to a number "16" that is bold.

PHP as Command-Line (CLI)
  • You can run PHP on the command line without requiring a server or a web browser. You can use PHP as CLI with cron or task scheduler to automate your website and applications (for example, deleting inactive users older than 2 weeks.) You can also use PHP as CLI to accept input and create automated tasks with a command line interpreter, for example a basic CLI application to accept input (age, life style, etc), process data and return a result (estimation of death date) back to the user.

PHP as a GUI Application
  • With the help of PHP-GTK, you can create a GUI application with PHP. Please note, it may not be very effective to create GUI applications with PHP, and it would be more efficient and effective to create GUI applications with another language such as Java, C#, or Python.
2. How to Learn PHP
  • PHP is an easy programming language to grasp the concept of. If you would like to learn PHP, then you will need to determine which method of learning works best for you. If you prefer reading, you may find books and written tutorials best, if you prefer seeing someone else writing PHP code and explaining it while you follow along, you may find video tutorials best. Or you may prefer diving straight to PHP code and figuring out how it works, whilst following a tutorial.

    Before you begin PHP, you should understand the very basics of HTML, you do not need to know everything about HTML (it is pretty simple) only the basics (tags/elements, attributes, etc.)

    The best way for you to learn PHP, is to setup a development environment, and play around with PHP code, you can do this while following a tutorial. Having your own development environment allows you to experiment with PHP code.
3. Setting up a PHP development environment
4. PHP Open Source Applications
  • There are many large and open source applications that are written in PHP, a few common ones are listed below. These applications are 100% free and open source, allowing you to grab a copy and do whatever you’d like with it. These applications have their own pros and cons.

    Content Management System (CMS):
    • Wordpress - A popular open source application that allows you to create a website. WordPress is commonly used for blogs. WordPress has a large community, and a large documentation, with a wide variety of themes and plugins. WordPress is very user friendly, and easy to use, a great application to power clients' websites. Depending on how large a Wordpress website is, may reduce the overall performance of the website. (https://wordpress.org/)
      Joomla - A very powerful CMS that gives you a wide variety of customisation for your website. However, for beginners and the non-technical, it may be difficult to understand how to use Joomla. It is also great to run a commercial website. (http://www.joomla.org/)
      Drupal - Another powerful CMS that has been built to power a wide variety of websites. Drupal offers a wide variety of customisation options, and shows great performance. (https://www.drupal.org/)
      myBB - A popular forum software that is powering many large forums (including HackForums!) with lots of customisation and modding support, it is a great software to run a forum. (http://www.mybb.com/)

    Frameworks:
    • Laravel - A popular PHP framework, bundles many libraries into a powerful framework. Laravel uses newer coding practices and security features. Laravel contains many features which ease the development of website applications. Includes an ORM, a powerful templating engine, a powerful router, it is a great framework to run large website applications. (http://laravel.com/)
      Kohana - A fast, and lightweight framework that allows a great way to extend base framework classes. (https://kohanaframework.org/)
      Symfony - Used by many large websites and applications. Many open source projects such as: Drupal, phpBB, and Laravel uses Symfony. (http://symfony.com/)
      Slim - A micro framework that can be used for small website applications, containing a router, template engine, caching, error handlers and more. It is recommended for very small or lightweight applications. (http://www.slimframework.com/)

    PHP Libraries:
    • PHPMailer - A PHP library that allows you to easily send emails, including many features such as email attachments. Utilising SMTP and the mail function, this is the perfect way to send emails. (https://github.com/PHPMailer/PHPMailer)
5. PHP Resources & Tutorials
6. Final Remarks
  • I am hoping to improve this thread significantly. I will gladly appreciate and accept all suggestions to help me out improve this thread. If you know of any valuable resources and tutorials for beginners, feel free to let me know!

Special Thanks:
  • Thanks to MineSQL for some assistance with this thread! <3
Nice thread, can't wait to see the future parts of it! You should link to the sections in the table of contents!
~ Reserving this post for possibly a future use ~
Reported all the shitposters above.
Nice thread OP.
I'm bookmarking it for reading it in the future.
Is it me or was your answer to that maths equation incorrect?
(Dec 27, 2014 09:06 PM)TomasKali Wrote:  Is it me or was your answer to that maths equation incorrect?

Woah I have no clue why it was incorrect. I've changed it. Thanks for the correction!
Nice introduction thread. I may mention that you have a link to the Drupal website next to the MyBB description which could be fixed. 😝
Some good resources for those looking to learn PHP, nice thread OP. I know from experience that simple layouts like this take time and effort.
Very very very very nice tutorial brother. I wish you also write more tutorial of PHP here. Though you also provide Links for learn but you Explanation way is way better. Thanks 🤝


Possibly Related Threads...
Thread / Author Replies Views Last Post
[PHP] by CarrotMilkMay 10, 2024 05:25 PM 101 3,867 May 10, 2024 05:25 PM
Last Post: imaskiles741
[PHP] by 1n9i9c7omSep 4, 2014 11:50 PM 38 3,661 Sep 4, 2014 11:50 PM
Last Post: Nivarka
[PHP] by GaBaNoNov 29, 2012 03:21 PM 37 892 Nov 29, 2012 03:21 PM
Last Post: CarrotMilk