Basics of PhP
What Will I Learn?
In This Tutorial, We are learning basic knowledge of PhP. First of all , We have to know what is php .
PHP : PHP stands for HyperText Pre Processor. Php is widely used open source scripting language. It is also known as- Interpreted Language and Loosely Typed Language .
- In this Tutorial , we will learn different types of ( Hello World ) Print and variable declaration ,variable print, Constant declaration.
- We will also learn Adding Two Numbers
- Also Learn PhP Operators.
Requirements
Specially, There is no requirements to learn PhP . But It is used for web development work . So ,If we learn HTML, XML, CSS, JavaScript besides PhP . It will good for development and also learn how the web works.
Difficulty
There is no difficulty in this tutorial . It is basics and easy to learn.
- Basic
Tutorial Contents of Basic php
php runs on the server. It generates dynamic page content. It can be used to control user access. It can collect form data. It is also encrypting data.
php is a scripting language : It's suited to server site web development, in that case it's generally runs on a server. So, We can tell php is a scripting languages.
php is a loosely typed language: Donot Declare any variable type. So we can tell php is a loosely typed language.
In this Tutorial , we will show different types of Hello World Print .
Let's see an example of Hello World :
<?php
echo "Hello World";
ECHO "Hello World";
Print "Hello World";
echo ("Hello World");
print ("Hello World");
?>
OutPut of the following code :
Let's see the difference between Print and echo :
php variable : There are some rules for php variables :
- varibale name start with a letter or _ character, but cannot start with a number.
- Variable names are case sensitive.
- can not contain space.
Here is an example of Variable declaration and Variable Print :
<?php
$p=10; //variable declare
echo $p; // variable print
?>
OutPut Of the Following Code :
php Constants : A Constant is an Identity of a value. It cannot be changed the value.
Let's see an example of the Constant-
<?php
define ("pie",3.14);
echo pie;
?>
Output of the Following Program :
Addition : Here We can see the additon -
<?php
var_dump(10+20); // result : 30
var_dump(10+20.5); // result :30.5
var_dump(10+"ABC"+30); // result : 40
var_dump(10.5+"ABC"); // result :10.5
var_dump("ABC"+"ABC"); // result : 0
var_dump(10+"10"); // result : 10
var_dump("10"+"10"); // result : 0
var_dump(true+10); // result : 11
var_dump(true+false); // result : 1
var_dump(true+"ABC"); // result : 1
?>
php Comparison Operators : Compare between two values .Let's see an example of Comparison Operators -
<?php
var_dump(10==10);
echo "<br/>";
var_dump(10===10);
echo "<br/>";
var_dump(10==10.0); //equality
echo "<br/>";
var_dump(10===10.0); //identical
echo "<br/>";
var_dump(10!=10.0);
echo "<br/>";
var_dump(10!==10.0);
echo "<br/>";
var_dump(5!=10.0);
echo "<br/>";
var_dump(5!==10.0);
echo "<br/>";
var_dump(5!=10.0);
echo "<br/>";
var_dump(10!==10.0);
echo "<br/>";
var_dump(10!=10.0);
echo "<br/>";
var_dump(5!==10.0);
?>
Output of the following program-
php Arithmetic Operators : There are some Arithmetic Operators like Addition, Subtraction, Multiplication, Division,Modulus , Exponentiation.
Let's see the example of Arithmetic Operators -
Addition Arithmetic Operators -
<?php
$p=5;
$q=5;
echo $p+$q;
?>
Output of the following program:
Subtraction Arithmetic Operator :
<?php
$p=6;
$q=5;
echo $p-$q;
?>
Output of the following program :
Multiplication Arithmetic Operator :
<?php
$p=6;
$q=5;
echo $p*$q;
?>
Output of the following program :
Division Arithmetioc Operator :
<?php
$p=20;
$q=3;
echo $p/$q;
?>
OutPut of the following Program :
Modulus Arithmetic Operator :
<?php
$p=20;
$q=3;
echo $p%$q;
?>
Output of the following result :
Posted on Utopian.io - Rewarding Open Source Contributors
Your contribution cannot be approved because it does not follow the Utopian Rules.
You can contact us on Discord.
[utopian-moderator]
Hey @jestemkioskiem, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!
This post has received a 0.72% upvote from thanks to: @mcplexer.
For more information, click here!!!!
Send minimum 0.050 SBD|STEEM to bid for votes.
Do you know, you can also earn daily passive income simply by delegating your Steem Power to @minnowhelper by clicking following links: 10SP, 100SP, 500SP, 1000SP or Another amount