What is PHP Language? How to start with basic code of PHP?
In this article, you will know all about PHP Language from basic to high. we will tell you all about PHP usage and details. as you know in today’s programming PHP Language comes the most useful language every web designers and web developers need to learn it because without this you can’t develop your website. in online websites, if you see there is PHP coding, the developer developed it with PHP.
PHP is the most popular scripting language. with this language, you can develop your web pages, like what things we can do with PHP? with this language, you can create a login form, registration form, gallery, and many more things. PHP Language is known as a server-side language, it doesn’t execute on your computer without a server.
What is HTML5? With full Definition, Tags, and Example 5 Best HTML Editor in 2019
what PHP stands for:
PHP stands for is “Hypertext Preprocessor“. But that would make it HPP, surely? An alternative explanation is that the initials come from the earliest version of the program, which was called Personal Home Page Tools. so now you get what is it stands for.
So you get a little about PHP, now I told you that PHP is a server-side language it doesn’t run your code without a server. you need to install server on your computer to run your code, don’t worry I will tell you how to get a server on your computer.
For windows users, we have WAMP server to install on Windows PC. and for MacOS users we have XAMP server to install on your PC. but I will tell you about WAMP server so let’s install wamp on your computer you can download wamp from this link download Wampserver 64bit for Windows PC download Wampserver 32bit for Windows PC
How to install WAMPServer on PC
- Double click on the downloaded file and just follow the instructions. Everything is automatic. The WampServer package is delivered with the latest releases of Apache, MySQL, and PHP.
- Once WampServer is installed, you can manually add additional Apache, Php or MySql (only VC9, VC10, and VC11 compiled) versions.
- Each release of Apache, MySQL, and PHP has its own settings and its own files (data for MySQL).
select language and click ok
accept the agreement and click on next button
Click on next button
set the installation folder on your PC and click next button
now your installation is ready to install so click on install button to install wamp
now you install Wampserver successfully on your computer.
- go to your local disk c:// and open wamp folder
- The “www” directory will be automatically created (usually c:\wamp\www)
- Create a subdirectory in “www” and put your PHP files inside.
- Click on the “localhost” link in the WampSever menu or open your browser and go to the URL: http://localhost
so now you created your folder and PHP file so now you need to open wamp.
Launching your first PHP scripts
Suppose you have created a PHP script called index.php. and you want to open it on the browser to open your browser and type
don’t type like this because localhost find www so you don’t need to type in URL
now your folder and PHP file is ready and Wampserver is also ready so let’s start php coding.
before coding, I should tell you about the variable.
What is Bootstrap? Learn From Basic with Examples What is CSS? Cascading StyleSheet With Full Details and Examples
What is a Variable?
Variable is just storage you put the value inside it and store it. as you store number and text. variable take space in memory each variable have it’s own space that further, we can do anything with it. now I give you example you will get more,
we have 2 variable by the name of a and b.
$a = 10;
a is variable name after variable name use equal sign (=) and put the value of a that I give 10 after value put a semicolon at the last. don’t forget semicolon is must to put at the last. one thing more variable can only be text and number nothing else. and with the variable name put dollar sign it is just because it modifies variable.
$b = 20;
here is the same b is a variable name and after that use equal sign and its value.
so now we need one variable more to put both variables inside it like.
$c = $a + $b;
so the answer is 30. if we sum $a and $b the result will be 30 because value of $a is 10 and value of $b is 20 so the value of $c will be 30.
Let’s do it practice:
now let’s do practice.
PHP Conditional Logic:
we have many types of Conditional Logic like.
- If statements
- If else statements
- Else if statements
- Comparison operators
- NOT equal to
- Less than and Greater than
- The switch statement
- logical operators
- Boolean Values
Let’s start with if statements.
usually if statements used on the time like for example it gives a command that does this thing or doesn’t do this thing like how now I will give you example
If else statement.
if, if else and else if are likely similar they all do the same task but there coding is somehow change. now I will give you If else example.
now I will show you how to work with loop statement in PHP and how to do a loop with it.
Loop is something that goes around and around until you tell to stop. you also need to tell a loop from where to start and till where to stop and after stopping the loop then what things they should do.
simply you can do code without loop also like $ans = 1+2+3+4 then print $ans; but if there will be 1000 number so can you type it again and again of course no so here you need a loop to run your code till 1000 .
it means that start loop from initial like start value from 0.
it means that do loop till the number we give you like I give less than 11 so the loop will end in 10 number.
it means that after each number of loop increase the value or increase/sum the number like how the first-time loop run the value is 1 then the second time it increases then the value be 2 then the third time it increases then the value be 3 ….. like this it will do. till the loop end.
so after that, if loop stops so what it should do as I print $a so it will print the value of $a that is 1.
as we have many loops like while loop, do while loop. but I will write an article about that.
so here I told you all the basic of PHP that a beginner should know and now apply it and do it practically.
if you don’t know which HTML editor to use so here is the link that I published an article about best HTML Editor.