Формат php чем открыть на андроиде
Перейти к содержимому

Формат php чем открыть на андроиде

  • автор:

What is PHP? The PHP Programming Language Meaning Explained

Kolade Chris

Kolade Chris

What is PHP? The PHP Programming Language Meaning Explained

PHP is an open-source server-side scripting language that many devs use for web development. It is also a general-purpose language that you can use to make lots of projects, including Graphical User Interfaces (GUIs).

In this article, I will help you explore the world of PHP so you can learn how it works and its basic features. By the end, you will be able to write your first Hello World program in PHP.

What Does PHP Mean?

The abbreviation PHP initially stood for Personal Homepage. But now it is a recursive acronym for Hypertext Preprocessor. (It’s recursive in the sense that the first word itself is an abbreviation, so the full meaning doesn’t follow the abbreviation.)

The first version of PHP was launched 26 years ago. Now it’s on version 8, released in November 2020, but version 7 remains the most widely used.

PHP runs on the Zend engine, which is the most popular implementation. There are some other implementations as well, like parrot, HPVM (Hip Hop Virtual Machine), and Hip Hop, created by Facebook.

PHP is mostly used for making web servers. It runs on the browser and is also capable of running in the command line. So, if you don’t feel like showing your code output in the browser, you can show it in the terminal.

Advantages of PHP

PHP has some advantages that have made it so popular, and it’s been the go-to language for web servers for more than 15 years now. Here are some of PHP’s benefits:

  • Cross-Platform: PHP is platform-independent. You don’t have to have a particular OS to use it because it runs on every platform, whether it’s Mac, Windows, or Linux.
  • Open Source: PHP is open source. The original code is made available to everyone who wants to build upon it. This is one of the reasons why one of its frameworks, Laravel, is so popular.
  • Easy to learn: PHP is not hard to learn for absolute beginners. You can pick it up pretty if you already have programming knowledge.
  • PHP syncs with all Databases: You can easily connect PHP to all Databases, relational and non-relational. So it can connect in no time to MySQL, Postgress, MongoDB, or any other database.
  • Supportive Community: PHP has a very supportive online community. The official documentation provides guides on how to use the features and you can easily get your problem fixed while stuck.

Who Uses PHP

A number of established companies and tech giants use PHP to run their servers and make a lot of incredible things.

  • Facebook: Facebook uses PHP to power its site. In turn, the company contributed to the community by creating an implementation known as Hip Hop for PHP.
  • Wikipedia: one of the world’s largest sources of information on any topic, Wikipedia is built in PHP.
  • Content Management Systems (CMSs): the world’s most popular content management system, WordPress, is built in PHP. Other content management systems such as Drupal, Joomla, and Magento are also built in PHP. Shopify runs on PHP too.
  • Web Hosting Platforms: a lot of Web Hosting Platforms such as BlueHost, Site ground, and Whogohost run their hosting servers using PHP.

Is PHP Dying?

Nowadays, there’s an intense debate on whether PHP is on the decline or not. This is because of the advent and increasing popularity of other languages suited for the server-side such as JavaScript (Node JS), Python, Golang, and others.

php-meme

This has actually led to a lot of funny memes targeting PHP

But is PHP really dying? The answer is no. Despite some people bashing on it and the claims of decline, PHP is still used to run the servers of almost 80% of all websites today. So, if you visit 10 websites a day, there’s a chance that 8 of them use PHP.

In terms of job availability, PHP ranks better than a lot of other programming languages on the job platform Indeed. A lot of PHP developers make a good living making WordPress themes and plugins every year – the average PHP developer in the US makes $86,000 per year.

php-jobs

How to Write Your First Hello World Program in PHP

Now that you have learned about PHP and its advantages, it’s time to write your first Hello World program in it!

First of all, you must have PHP installed on your local machine. You can get that done by installing an XAMP (Cross-Platform, Apache, MySQL, and PHP) or WAMP (Windows, Apache, MySQL, and PHP) server.

XAMP works on all operating systems and WAMP works only in Windows. I will be using WAMP.

Open up the WAMP or XAMP server and make sure all services are running. If you are using WAMP, the WAMP logo should show on your taskbar with the color green.

wamp-running

Open up your C drive and look for the installation directory of your WAMP server. In my case, it is wamp64 .

wampfolder

Open the installation directory, and then the www folder.

wwwfolder

Create a folder right there and name it whatever you want, then open up the folder with your code editor.

Create an index.php file and paste in the following code:

You can also put your “Hello World” text in a variable, then use the echo system to display it in the browser.

In PHP, you can declare a variable with the dollar sign ($). Your statements, apart from the last one, must also be terminated by a semi-colon.

To run your code in the browser, open up the browser and write this in the address bar localhost/the-folder-of-your-php-file/php-file.php , then hit enter.

Make sure your WAMP or XAMP server is running, otherwise it won’t work.

hello-world

You can see that the code successfully ran in the browser, because I got the file path right.

Another beautiful thing about PHP is that you can embed it in HTML. You can do it like this:

      PHP Code   

This is the result of a PHP Code embedded in HTML

"; echo $campers ?>

php-in-html

Conclusion

PHP remains a relevant and widely-used language in web development. Despite the mockery and debate on whether it’s still valuable, PHP developers keep earning good livings from working with the language. So, PHP doesn’t seem to be going anywhere anytime soon.

Now, go code some PHP!

Thank you for reading, and keep coding.

PHP Introduction

The term PHP is an acronym for – Hypertext Preprocessor . PHP is a server-side scripting language designed specifically for web development. It is open-source which means it is free to download and use. It is very simple to learn and use. The file extension of PHP is “.php”.

PHP was introduced by Rasmus Lerdorf in the first version and participated in the later versions. It is an interpreted language and it does not require a compiler.

Characteristics of PHP

  • PHP code is executed in the server.
  • It can be integrated with many databases such as Oracle, Microsoft SQL Server, MySQL, PostgreSQL, Sybase, and Informix.
  • It is powerful to hold a content management system like WordPress and can be used to control user access.
  • It supports main protocols like HTTP Basic, HTTP Digest, IMAP, FTP, and others.
  • Websites like www.facebook.com and www.yahoo.com are also built on PHP.
  • One of the main reasons behind this is that PHP can be easily embedded in HTML files and HTML codes can also be written in a PHP file.
  • The thing that differentiates PHP from the client-side language like HTML is, that PHP codes are executed on the server whereas HTML codes are directly rendered on the browser. PHP codes are first executed on the server and then the result is returned to the browser.
  • The only information that the client or browser knows is the result returned after executing the PHP script on the server and not the actual PHP codes present in the PHP file. Also, PHP files can support other client-side scripting languages like CSS and JavaScript.

Origin and History

  • PHP was created by Rasmus Lerdorf in 1994 and initially stood for “Personal Home Page.” Over the years, it evolved into “PHP: Hypertext Preprocessor.”
  • PHP is open-source and has a large community of developers contributing to its development.

Purpose of using PHP

  • PHP is primarily used for server-side web development. It enables the creation of dynamic web pages by embedding PHP code within HTML.
  • PHP can perform various tasks, including handling form data, generating dynamic page content, managing databases, and interacting with servers.

Syntax

Example:

HTML

< title >PHP Hello World

Output:

Hello, World! This is PHP code 

Features of PHP

  • Dynamic Typing: PHP is dynamically typed, meaning you don’t need to declare the data type of a variable explicitly.
  • Cross-Platform: PHP runs on various platforms, making it compatible with different operating systems.
  • Database Integration: PHP provides built-in support for interacting with databases, such as MySQL, PostgreSQL, and others.
  • Server-Side Scripting: PHP scripts are executed on the server, generating HTML that is sent to the client’s browser.

Why should we use PHP?

PHP can actually do anything related to server-side scripting or more popularly known as the backend of a website. For example, PHP can receive data from forms, generate dynamic page content, can work with databases, create sessions, send and receive cookies, send emails, etc. There are also many hash functions available in PHP to encrypt users’ data which makes PHP secure and reliable to be used as a server-side scripting language. So these are some of PHP’s abilities that make it suitable to be used as a server-side scripting language. You will get to know more of these abilities in further tutorials.
Even if the above abilities do not convince you of PHP, there are some more features of PHP. PHP can run on all major operating systems like Windows, Linux, Unix, Mac OS X, etc. Almost all of the major servers available today like Apache supports PHP. PHP allows using a wide range of databases. And the most important factor is that it is free to use and download and anyone can download PHP from its official source: www.php.net .
Please refer to setting up the development environment to setup and run PHP programs.

What’s new in PHP 7.0?

  • PHP 7 is faster than the previous versions.
  • PHP 7 supports new operators.
  • PHP 7 supports better Error Handling functionalities.
  • PHP 7 supports stricter declarations for types in function parameters.

Advantages of PHP

  • Open Source: PHP is an open-source language, making it freely available for use and distribution. This encourages a large community of developers, contributing to its growth and improvement.
  • Easy to Learn: PHP syntax is similar to C and other programming languages, making it relatively easy for developers to learn, especially for those with a background in programming.
  • Web Integration: PHP is designed specifically for web development and is embedded within HTML. It seamlessly integrates with various web technologies, facilitating the creation of dynamic and interactive web pages.
  • Database Support: PHP has excellent support for various databases, including MySQL, PostgreSQL, SQLite, and more. This makes it easy to connect and interact with databases, a crucial aspect of many web applications.
  • Cross-Platform Compatibility: PHP is platform-independent and runs on various operating systems, including Windows, Linux, macOS, and others. This ensures compatibility across different environments.
  • Large Community and Documentation: PHP has a vast and active community of developers. The abundance of online resources, tutorials, and documentation makes it easier for developers to find solutions and seek help when needed.
  • Frameworks and CMS: There are popular PHP frameworks like Laravel, Symfony, and CodeIgniter, which provide pre-built modules and features, aiding in rapid development. Additionally, PHP supports widely used content management systems (CMS) like WordPress and Joomla.
  • Server-Side Scripting: PHP scripts are executed on the server, reducing the load on the client’s side. This server-side scripting capability is crucial for generating dynamic content and performing server-related tasks.
  • Community Support: The PHP community actively contributes to the language’s development, ensuring regular updates, security patches, and improvements.

Disadvantages of PHP

  • Inconsistency: PHP has been criticized for inconsistencies in function names and parameter orders. This can lead to confusion for developers, especially when working with a mix of older and newer functions.
  • Security Concerns: If not handled properly, PHP code may be susceptible to security vulnerabilities, such as SQL injection and cross-site scripting (XSS). Developers need to be cautious and follow best practices to secure PHP applications.
  • Performance: While PHP performs well for many web applications, it may not be as fast as some compiled languages like C or Java. However, advancements and optimizations in recent versions have improved performance.
  • Lack of Modern Features: Compared to newer languages, PHP may lack some modern language features. However, recent versions of PHP have introduced improvements and features to address this concern.
  • Scalability Challenges: PHP can face challenges when it comes to scaling large and complex applications. Developers may need to adopt additional tools or frameworks to address scalability issues.
  • Not Suitable for Large-Scale Applications: While PHP is suitable for small to medium-sized projects, it might not be the best choice for extremely large and complex applications where more structured languages might be preferred.
  • Limited Object-Oriented Programming (OOP) Support: Although PHP supports OOP, its implementation has been criticized for not being as robust as in some other languages. However, recent versions have introduced improvements to enhance OOP capabilities.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *