w3resource logo
php exercises

PHP Exercises, Practice, Solution

What is PHP?

PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.

The best way we learn anything is by practice and exercise questions. We have started this section for those (beginner to intermediate) who are familiar with PHP.

Hope, these exercises help you to improve your PHP coding skills. Currently, following sections are available, we are working hard to add more exercises. Happy Coding!

Note: It's fine if you are playing around with PHP codes with the help of an online PHP editor, to enjoy a full-fledged PHP environment (since online editors have several caveats, e.g. embedding PHP within HTML) up and running on your own machine is much better of an option to learn PHP. Please read our installing PHP on Windows and Linux if you are unfamiliar to PHP installation.

List of PHP Exercises:

PHP Challenges:

Note: You may accomplish the same task (solution of the exercises) in various ways, therefore the ways described here are not the only ways to do stuff. Rather, it would be great, if this helps you anyway to choose your own methods.

Popularity of Programming Language Worldwide, Aug 2017 compared to a year ago

PYPL Popularity of Programming Language Index:

Rank Change Language Share Trend
1 Java 22.7 % -0.7 %
2 Python 16.3 % +3.7 %
3 PHP 8.9 % -1.1 %
4 C# 8.3 % -0.5 %
5 Javascript 8.0 % +0.5 %
6 C++ 6.6 % -0.2 %
7 C 6.4 % -0.7 %
8 up arrow R 3.6 % +0.4 %
9 down arrow Objective-C 3.6 % -1.2 %
10 Swift 2.8 % -0.3 %
11 Matlab 2.3 % -0.2 %
12 Ruby 1.8 % -0.5 %
13 up arrow VBA 1.5 % +0.0 %
14 down arrow Visual Basic 1.4 % -0.3 %
15 up arrow TypeScript 1.3 % +0.4 %
16 down arrow Scala 1.2 % +0.1 %
17 down arrow Perl 0.8 % -0.3 %
18 up arrow Go 0.6 % +0.2 %
19 up arrow Kotlin 0.6 % +0.5 %
20 down arrow lua 0.4 % -0.1 %
21 up arrow Rust 0.3 % +0.1 %
22 down arrow Haskell 0.3 % +0.1 %
23 down arrow Delphi 0.3 % -0.1 %

Source : http://pypl.github.io/PYPL.html

Note: The PYPL Popularity of Programming Language Index is created by analyzing how often language tutorials are searched on Google.

TIOBE Index for August 2017:

Aug 2017 Aug 2016 Change Programming Language Ratings Change
1 1 Java 12.961% -6.05%
2 2 C 6.477% -4.83%
3 3 C++ 5.550% -0.25%
4 4 C# 4.195% -0.71%
5 5 Python 3.692% -0.71%
6 8 up arrow Visual Basic .NET 2.569% +0.05%
7 6 down arrow PHP 2.293% -0.88%
8 7 down arrow JavaScript 2.098% -0.61%
9 9 Perl 1.995% -0.52%
10 12 up arrow Ruby 1.965% -0.31%
11 14 up arrow Swift 1.825% -0.16%
12 11 down arrow Delphi/Object Pascal 1.825% -0.45%
13 13 Visual Basic 1.809% -0.24%
14 10 down arrow Assembly language 1.805% -0.56%
15 17 up arrow R 1.766% +0.16%
16 20 up arrow Go 1.645% +0.37%
17 18 up arrow MATLAB 1.619% +0.08%
18 15 down arrow Objective-C 1.505% -0.38%
19 22 up arrow Scratch 1.481% +0.43%
20 26 up arrow Dart 1.273% +0.30%

Source : https://www.tiobe.com/tiobe-index/

Note: The ratings are based on the number of skilled engineers world-wide, courses and third party vendors. Popular search engines such as Google, Bing, Yahoo!, Wikipedia, Amazon, YouTube and Baidu are used to calculate the ratings.

List of Exercises with Solutions :

[Want to contribute to PHP exercises? Send your code (attached with a .zip file) to us at w3resource[at]yahoo[dot]com. Please avoid copyrighted materials.]