How to learn PHP in MacOS X with complete php setup

In this section, we gave a tutorial about How to set up and learn PHP in OS X. Before continuing this guide How to set up and learn PHP in OS X let us know If you need any help regards this via comment sections.

Learning PHP is a good suggestion. PHP (a recursive acronym for PHP Hypertext Preprocessor) is a scripting language. It is the facility behind a number of the largest web sites in the world, together with Facebook, Wikipedia and WordPress.

Learning PHP helps you as a programmer. You’ll run into PHP on a regular basis when engaged on web sites, and it is a good way to add programming oomph to your HTML and CSS primarily based web site. PHP permits you to create virtually something scripts.

PHP is the standard marmite of programming languages. Many professionals fee it fairly poorly, in half as a result of it’s so simple for novices to use (main to many errors); it additionally comprises a whole lot of outdated code, making it clunky in contrast to Ruby or Javascript.

Don’t let the naysayers distract you. If you need to create code online, you could have to spend time studying how PHP works.

Learning to code: how to set up and learn Python coding on a Mac

Setting up and studying PHP in OS X: what’s PHP?
Install PHP in OS X

PHP is a normal function scripting language. While HTML shows textual content and CSS kinds, PHP is a programming language that may automate duties. It is commonly used to get info from the person or to make API (Application Programming Interface) calls to different web sites and online companies. You can management program circulate and logic gates in PHP and use it as a programming language.

PHP is barely totally different from Javascript (the same language) in that the code runs in your server and then sends HTML to the browser. So the browser will get the outcomes, however, can’t see the code. By executing code on the server aspect, PHP is nice for safety as a result of the browser doesn’t see the code. It additionally signifies that PHP will not be depending on browser pace or settings.

How to learn PHP: Set up PHP in OS X

Mac OS X comes with prepackaged PHP. So you do not have to do a lot to install PHP. Open a Terminal window and enter PHP –version to check which model you could have put in. If you’re utilizing OS X El Capitan, you will note PHP 5.5.31 (or increased). Ours says “PHP 5.5.31 (cli) (built: February 20, 2016 8:33:10 PM)”.

The newest steady launch is PHP 7.0, which you’ll install through Homebrew with brew install php70. If you do not have Homebrew, you may install it utilizing the script on the Homebrew web site.

However, we suggest sticking with PHP 5.5 in the quick time period. While PHP 7. Zero provides a whole lot of cool new options, most tutorials use PHP 5.5, and it’s nonetheless the model generally used in most programming environments.

Learn PHP: Hello world

PHP interactive mode

PHP interactive mode

Like Python, you may run PHP from a terminal in an interactive shell. Open Terminal and enter PHP -a to begin interactive mode. You ought to see “Interactive shell” and “php>”. Run ultrasound “Hello World!” In; to create your first line of code.

Not the “;” on the finish of the road. This signifies that you’ve got completed coming into a line of code. If you do not have “;” used on the finish it goes to the subsequent line “php>” so you may add more code. (You can enter “;” and press Return to run the code line).

Type exit to exit interactive mode.

Learn PHP: create an interactive script in PHP

Create a PHP script

Create a PHP script

Now that you have used the interactive PHP shell to enter instructions, you want to create a PHP script in a textual content file. Open your textual content editor and enter the next code:


if ($ argc! == 2) {

echo “Usage: php hello.php . n “;

output (1);


$ title = $ argv;

echo “Hello, $ name n”;

Save the file as howdy.php in your house folder and enter php howdy.php to run it. You ought to see “Usage: php hello.php ” This is as a result of this system wants an argument,” your name “after it. Enter php howdy.php John Appleseed and it is going to show” Hello John Appleseed “on the command line.

How to learn PHP: PHP studying sources

Now that you have set up PHP and began to experiment with the interactive shell and records data, you want to learn PHP properly. Here are some helpful PHP coaching sources:

I hope you like the article ” How to set up and learn PHP in OS X”. Still need help please comment below.