- Quick start guide
- System requirements
- Installation guide
- Administrators guide
- User guide
- Developers guide
- SMS from SQL
- C# SMS API
- HTTP SMS API
- PHP SMS API
- VB.NET SMS API
- Programming APIs
- C# SMS tutorial
- VB SMS tutorial
- F# SMS tutorial
- Java SMS tutorial
- Node.js SMS tutorial
- Kotlin SMS tutorial
- C/Cpp SMS tutorial
- Delphi SMS tutorial
- PHP SMS tutorial
- PHP send sms
- PHP multiple sms
- PHP schedule sms
- PHP receive sms
- PHP delete sms
- PHP sms Github
- Perl SMS tutorial
- Python SMS tutorial
- Python flask SMS tutorial
- Ruby SMS tutorial
- Tcl/Tk SMS tutorial
- Go SMS tutorial
- R SMS tutorial
- Scala SMS tutorial
- Objective C SMS tutorial
- Service providers
PHP tutorial: Hello world
This tutorial helps you get started with PHP. It explains what you need to write your first PHP program. It starts with the basics: you will learn where you can find and download the tools needed, how to install these tools and it will take you all the way to building and runing your code. If you have never written a PHP program before this is the place to start. We have created this article, so you can get started with PHP, and move on to our sms examples. If you are already familiar with PHP, you can jump directly to one of the following SMS projects.
PHP sms examples:
PHP send sms with the HTTP rest api (code sample)
PHP send multiple sms with the HTTP rest api (code sample)
PHP schedule sms with the HTTP rest api (code sample)
PHP receive sms with the HTTP rest api (code sample)
PHP delete sms with the HTTP rest api (code sample)
Download the latest PHP sms api library from Github
What is PHP
PHP is a server side programming language. It is similar to a natural language, like English. It is used to talk to a computer. The major difference between a natural language and a programming language is that, programming languages have a more rigorous structure, to help the computer understand it better.
What is WampServer
WampServer refers to a solution stack for the Microsoft Windows operating system consisting of the Apache web server, OpenSSL for SSL support,MySQL database and PHP programming language. We will use it to run the PHP code locally on our computer.
What is a PHP Hello world program
A hello world program is the most simple program you can write. It simply prints out the sententce: Hello world on the computer screen. The Hello World program is the first program developers write in any programming language.
How to write your first program in PHP
To write your first program in PHP:
- Check prerequisites
- Setup WampServer
- Clear the original index.php file
- Write Hello World program in PHP
- Use echo("Hello world!") for printing
- Run your PHP Hello World program
- Check the output in the browser
- Fix errors if needed
Here is what you need to get started. To write your first computer program in PHP, you need a Windows computer, WampServer and the example code presented below.
- Windows 10 computer
- Ozeki Hello World example project
To get started you have to visit the following link: https://www.wampserver.com/en/ and download the WampServer installer (Video 1).
Start by going to https://www.wampserver.com/en/ in your browser. Click on the Download button on the top to be automatically scrolled down to the downloads section. Click on WAMPSERVER 64 BITS (X64) to download the WampServer installer to your computer (Figure 1).
The next step after downloading WampServer is to install it. This video show you how you can successfully complete the setup. When you've installed WampServer, it will automaticaly start to run (Video 2). After the installation process finished, we can go on creating our first 'Hello world!' PHP program.
Write your 'hello world' program in PHP
In this part we are going to write our first PHP code using only the WampServer and a usual Windows nodepad.
First of all we should create a new file, called index.php in the
previously opened /www/ folder.
Notice: It is helpful if you enable the system to show the file extensions, I'll show you how to do that in the upcoming video. The naming is not optional, because the local server will automatically open the file that is named index.
The www folder
Next we need to open the www folder. This is located inside the wamp64 folder, which itself is inside the directory we install WAMP into. In the www folder, we need to either edit the existing index.php file, or delete it and create a new one (Figure 2). This file is where we are going to write the PHP code and run in in our browser.
<?php echo("Hello world!"); ?>
"Hello world!" code
As you can see in the (Code 1) example, every PHP code starts with an opening PHP tag <?php, and ends with a closing PHP tag ?>. Inside these tags we use the echo command to display our message, "Hello World!".
Writing the "Hello world!" program in PHP
This video tutorial shows you how you can write the "Hello World!" code in PHP language. This is done by modifying the index.php file in Notepad (Video 3). The code itself uses an opening and a closing tag. Inside these tags goes the echo command. The argument of the echo command is the actual message that gets displayed on the page.
Running your 'hello world' program in the browser
To run your PHP code you should refresh the website
and it will appear with the new content (Video 4).
Notice: It is important, that you have to save your PHP files into the www folder!
Output of the code
After you wrote your code you may now open it in your browser by typing http://localhost/ into your URL bar (Figure 3). Upon opening it, you can see that it displays the "Hello World!" message. This indicates that your code runs correctly. Now let's see what happens if the syntax of your code is not correct.
What happens if I make a mistake in PHP
If you make a mistake in your PHP code, if you run your code the complier will alert you about you mistakes.
In our example we will remove one of the quote marks from the echo("Hello world!"); line.What is syntax error in PHP?
Syntax error means I don't understand. If you talk to somebody in English and he does not understand what you say, he will reply with "I don't understand". If you talk to a computer in PHP and the computer does not understand what you say, he will reply with "Syntax error".
In the code below we will create a mistake intentionally by not putting a semicolon after the Hello World line. You will see, how the computer reacts, how we fix the error, and how we run the computer program successfully.
How to handle a syntax error in PHP?
In the code below we will create a syntax error intentionally by not putting a semicolon after the Hello World line. You will see, how the computer reacts, how we fix the error, and how we run the computer program successfully.
Making and fixing an error
In this video we aregoing to make an error in our PHP code on purpose. This will not run the code, therefore not display the message. An error message gets displayed instead (Video 5).
Error message in PHP
When there is an invalid syntax in the PHP code, the code will fail to run. Here we can see that instead of "Hello World!", an error message appears (Figure 4). This message contains information about the type of error and where it occured. This is incredibly helpful for the developer, because it makes it easier to identify and fix mistakes in the code.
This article explained how to get all the prerequisites for learning to code in PHP and how to write and run your first Hello World program. Now I recommend you to apply the Ozeki PHP SMS solutions for message organization, it offers proper, well-written method calls and a well-designed SMS class to allow you to configure the SMS parameters. Using PHP SMS API is great because it allows you to organize SMS messages the way you need and the Ozeki SMS Gateway provides excellent operating speed.
You may find out more information about this technology and the Ozeki SMS Gateway, so make sure that you continue reading. It is a good idea to check out the tutorial about how to send SMS from PHP.
Now your next thing to do is to download the Ozeki SMS Gateway and let the work begin!
- C# SMS tutorial: Hello world
- Visual Basic SMS tutorial: Hello world
- F# SMS tutorial: Hello world
- Java SMS tutorial: Hello world
- Node.js SMS tutorial: Hello world
- Kotlin SMS tutorial: Hello world
- C/C SMS tutorial: Hello world
- Delphi SMS tutorial: Hello world
- Perl SMS tutorial: Hello world
- Python SMS tutorial: Hello world
- Python flask SMS tutorial: Hello world
- Ruby SMS tutorial: Hello world
- Tcl/Tk SMS tutorial: Hello world
- Go SMS tutorial: Hello world
- R SMS tutorial: Hello world
- Scala SMS tutorial: Hello world
- Objective C SMS tutorial: Hello world
- Tutorials for software developers