PHP Tutorial – Part 1 – Info PHP
PHP First Program
Today we start the first program in PHP before starting we should know some points.
- After installing xampp, we save all our codes file (myfirstpage.php file) in the “C:xampphtdocs” folder.
So now Start the xampp server and Start Apache and MySQL, then start notepad++ and select language from the menu bar and select PHP.
In the XAMPP I captured the screenshot after clicking Start.
The first program.
- To execute the code we access our computer as a web server and domain name is localhost or access by local IP 127.0.0.1.
- The htdocs is the root folder of our local web server. To execute the file we enter the following URL in our browser: localhost/myfirstpage.php.
- Then the program will execute.
Do you have a a question what is echo? Yes!
The echo is the function that prints the data on the screen. The print() is the old version of echo and it is not used so much used in the coding.
Understanding variables is very simple in php . There are some rules about PHP variables.
- First character must start with dollar sign ($).
Example: $count = 0;
- At least one character should be in the variable except $.
- We can use underscore in the variable name.
Example: $Adhaar_number ;
- Spaces and special character other than (_) and ($) are not allowed.
Some rules that are least important but good for coding skills.
- Always the variables name are in lowercase.
- To separate multiword use (_) sign.
Now the time is to see an example of Variable.
You can print the variables using the echo function.
So there are many things you can understand by only seeing this example. I am now explaining one by one:
- The is no data type written before variable language unlike other programming languages like C, C++, Java, etc.
- We only simply write dollar then variable name.
- If we give the value to a variable a int then the php act it as an int. Same in float, long, etc numerical variables.
- But when the value is in the inverted commas, php act it as a String. For example, $value=’100’,name =”RAdha”, $value =”100.876”, &value=’20.876’ these act as a string.
- If we talk about the Boolean, I thinl you know about that.
Article Prepared by Ollala Corp