Monday 17 February 2014

Assignment Operators in php

Assignment Operators in php
Assignement operators in php
This is tutorial of Assignment Operators in PHP With Examples.We have already seen a glimpse about these operators in previous tutorials eg. $number1 = 10; In this “equal to(=)” is assignment operator in php that is assigning value to number1 here sign “=” is not comparing variables but its assigning value to variables.

Assignment operators in php
Code for Assigment Operator Screenshot1
<?php



$number1 = 10;



$number1 += 2;



echo $number1;



?>




Output (Screenshot2):- 

assignment operators in php
Screenshot2
In this example,we are assigning variable $number1 = 10 and we can increment its value by taking $number1 += 2 ,which is an easy way to write code and its known as assignment operators.

Code for Assignment operators (Screenshot3):-

Code for assignment operator
Code for Assignment operator Screenshot3
<?php



$number1 = 10;



$number1 -= 2;



echo $number1;



?>

output (Screenshot4):-

Assignement operators in php
Screenshot4
Similarly as above, we can decrements its value by taking $number1 -= 2.

Code for Assignment operators (Screenshot5):-

Screenshot5
<?php



$number1 = 10;



$number1 *= 2;



echo $number1;



?>

output (screenshot6):-

Assignment operators in php
Screenshot6
Multiplication variables with Assignment Operators

Code for Assignment operators (Screenshot7):-


assignment operators in php
Screenshot7
<?php

$number1 = 10;



$number1 /= 2;



echo $number1;



?>

output (screenshot8):-

assignment operators
Screenshot8
Dividing variables with Assignment Operators

Code for Concatenate and Assignment operators (Screenshot9):-

Code for Concatenate and Assignment operators
Screenshot9
<?php



$text = 'Hello';



$text .= 'World';



echo $text;



?>

output (Screenshot10) :-

assignement operators in php
Screenshot10
In this we can concatenate with assignment operators.
$text .= ‘ World’;
concatenate with $text = ‘ Hello’
instead of this, we can write $text = ‘Hello’.'World’;.
This is example of how to concatenate string with other string using assignment operators.This are basic examples of assignment operators and how we can assign values of different variables or plain text itself in php.


No comments:

Post a Comment

Thanks For Comment Will get you Soon..

About Me

Welcome to Extra Tutorials! My name is Mohammed and I am the 22 year writer, website developer, and photographer behind the blog. Thanks for visiting! Tutorials Jackpot… In addition to Developer, I love to develop websites and I love to write. Starting a php Blog was inevitable for me. What began as a simple way to share all of my Tutorials with friends and family has developed into my Part time job.

Mohammed Padela

WHAT IS PHP PROGRAMMING

WHAT IS PHP PROGRAMMING
WHAT IS PHP PROGRAMMING

Follow Us

Popular Posts

Designed ByBlogger Templates