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, Jan 2022 compared to a year ago:

`
Rank Change Language Share Trend
1 Python 28.74 % -1.8 %
2 Java 18.01 % +1.2 %
3 Javascript 9.07 % +0.6 %
4 up arrow C/C++ 7.4 % +1.1%
5 down arrow C# 7.27 % +0.7 %
6 PHP 6.06 % +0.0 %
7 R 4.19 % +0.3 %
8 Objective-C 2.27 % -1.4 %
9 Swift 1.91 % -0.2 %
10 TypeScript 1.74 % -0.0 %
11 Matlab1.74% +0.0 %
12 Kotlin 1.71 % +0.0 %
13 Go 1.19 % -0.1 %
14 VBA 1.14 % -0.0 %
15 Ruby 1.07 % -0.0%
16 Rust 0.98 % -0.0 %
17 up arrow Ada 0.75 % +0.1 %
18 up arrow Dart 0.72 % +0.2 %
19 up arrow Abap 0.66 % +0.2 %
20 down arrow Visual Basic 0.64 % -0.0 %
21 down arrow Scala 0.48 % -0.2%
22 up arrow Groovy 0.48 % +0.1 %
23 down arrow Lua 0.42 % -0.2 %
24 down arrow Perl 0.38 % -0.1 %
25 up arrow Haskell 0.34 % +0.1 %
26 down arrow Julia 0.34 % -0.0 %
27 down arrow Cobol 0.3 % -0.0 %

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

TIOBE Index for January 2022

Jan 2022 Jan 2021 Change Programming Language Ratings Change
1 3 up arrow Python 13.58% +1.86%
2 1 down arrow C 12.44% -4.94%
3 2 down arrow Java 10.66% -1.30%
4 4 C++ 8.29% +0.73%
5 5 C# 5.68% +1.73%
6 6 Visual Basic 4.74% +0.90%
7 7 JavaScript 2.09% -0.11%
8 11 up arrow Assembly language 1.85% +0.21%
9 12 up arrow SQL 1.80% +0.19%
10 13 up arrow Swift 1.41% -0.02%
11 8 down arrow PHP 1.40% -0.60%
12 9 down arrow R 1.25% -0.65%
13 14 up arrow Go 1.04% -0.37%
14 19 up arrow Delphi/Object Pascal 0.99% +0.20%
15 20 up arrow Classic Visual Basic 0.98% +0.19%
16 16 MATLAB 0.96% -0.19%
17 10 down arrow Groovy 0.94% -0.90%
18 15 down arrow Ruby 0.88% -0.43%
19 30 up arrow Fortran 0.77% +0.31%
20 17 down arrow Perl 0.71% -0.31%

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

[ 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

PHP: Remove first 4 characters of a string with PHP

You could use the substr function to return a substring starting from the 5th character:

$str = "The quick brown fox jumps over the lazy dog."
$str2 = substr($str, 4); // "quick brown fox jumps over the lazy dog."

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