w3resource

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 2020 compared to a year ago:

Rank Change Language Share Trend
1 Python 31.59 % +3.3 %
2 Java 16.9 % -2.7 %
3 Javascript 8.17 % +0.0 %
4 C# 6.54 % -0.7%
5 up arrow C/C++ 5.88 % +0.1 %
6 down arrow PHP 5.78 % -0.7 %
7 R 4.18 % +0.3 %
8 Objective-C 2.6 % -0.0 %
9 Swift 2.35 % -0.0 %
10 up arrow TypeScript 1.94% +0.2 %
11 down arrow Matlab 1.63 % -0.2 %
12   Kotlin 1.57 % +0.1 %
13 up arrow Go 1.39 % +0.2 %
14 down arrow Ruby 1.22 % -0.2 %
15 down arrow VBA 1.19 % -0.1 %
16 Scala 0.97 % -0.1 %
17 up arrow Rust 0.91 % +0.3 %
18 down arrow Visual Basic 0.82 % -0.2 %
19 up arrow Dart 0.57 % +0.2 %
20 up arrow Ada 0.54 % +0.2 %
21 up arrow Lua 0.52 % +0.1 %
22 down arrow Perl 0.45 % -0.1 %
23 down arrow Abap 0.44 % -0.1 %
24 up arrow Julia 0.43 % +0.2 %
25   Cobol 0.42 % +0.1 %
26 down arrow Groovy 0.41 % -0.1 %
27 down arrow Haskell 0.32 % +0.0 %
28 Delphi 0.28 % +0.0 %

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

TIOBE Index for August 2020

Aug 2020 Aug 2019 Change Programming Language Ratings Change
1 2 up arrow C 16.98% +1.83%
2 1 down arrow Java 14.43% -1.60%
3 3 Python 9.69% -0.33%
4 4 C++ 6.84% +0.78%
5 5 C# 4.68% +0.83%
6 6 Visual Basic 4.66% +0.97%
7 7 JavaScript 2.87% +0.62%
8 20 up arrow R 2.79% +1.97%
9 8 down arrow PHP 2.24% +0.17%
10 10 SQL 1.46% -0.17%
11 17 up arrow Go 1.43% +0.45%
12 18 up arrow Swift 1.42% +0.53%
13 19 up arrow Perl 1.11% +0.25%
14 15 up arrow Assembly language 1.04% -0.07%
15 11 down arrow Ruby 1.03% -0.28%
16 12 down arrow MATLAB 0.86% -0.41%
17 16 down arrow Classic Visual Basic 0.82% -0.20%
18 13 down arrow Groovy 0.77% -0.46%
19 9 down arrow Objective-C 0.76% -0.93%
20 28 up arrow Rust 0.74% +0.29%

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

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.]

List of Exercises with Solutions :



PHP: Tips of the Day

Finding the number of days between two dates

$now = time(); // or your date as well
$your_date = strtotime("2010-01-31");
$datediff = $now - $your_date;

echo round($datediff / (60 * 60 * 24));

Ref : https://bit.ly/2ZDZ4as