Pages

Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Saturday, July 1, 2017

Detect the browser resolution by php and js

Detect the browser resolution by php and js


Code:




Read more »

Wednesday, June 28, 2017

Difference between echo and print in PHP

Difference between echo and print in PHP



PHP echo and print both are PHP Statement.

Both are used to display the output in PHP.
Difference Between Echo And Print In PHP
echo
  • echo is a statement i.e used to display the output. it can be used with parentheses echo( ) or without parentheses echo.
  • echo is faster then print
  • Using echo can pass multiple string seperated as ( , )
  • echo doesn�t return any value
Eg i
 <?php
$name="Ravi";
echo $name;
//or
echo ($name);
?>

 Output: Ravi

In the above example
Create and initialize variable($name) hold a string value=�Ravi�. we want to print the name for this ($name) variable declare inside the echo with or without parentheses .
it will display the same output.
Eg ii (pass multiple argument)
 <?php
$name = "Ravi ";
$profile = "PHP Developer";
$age = 25;
echo $name , $profile , $age, " years old";
?>

 Output: Ravi PHP Developer25 years old

In the above example
$name , $profile and $age are three variable with value=(�ravi� , �php developer� and 25) respectively.
now we want to print all three variable values together. all variables names are define inside the echo statement separated by comm or dot(, or .)
it will show the output
Eg iii (check return type)
 <?php
$name = "Ravi ";
$ret = echo $name;
?>

 Output: Parse error: syntax error, unexpected T_ECHO

In the above example
In this program we check the return type of �echo�. declare a variable $name with value=�ravi�.
now we check the return type. when we run the program it show error,because echo has no return type.
print
  • print is also a statement i.e used to display the output. it can be used with parentheses print( ) or without parentheses print.
  • it is slower than echo
  • using print can doesn�t pass multiple argument
  • print always return 1
Eg i
 <?php
$name="Ravi";
print $name;
//or
print ($name);
?>

 Output: Ravi

In the above example
Declare a variable ($name) value=�ravi�. now we want to print the name. we simply define $name inside print statement with or without parentheses.
it will show the output: �ravi� .
Eg ii (pass multiple argument)
 <?php
$name = "Ravi ";
$profile = "PHP Developer";
$age = 25;
print $name , $profile , $age, " years old";
?>

 Output: Parse error: syntax error
In the above example
Declare three variable $name, $profile, $age and hold the value(�ravi�,�php developer�,25).
now check whether it will allow execute multiple argument. Pass three variable inside the print statement separated by comma. as we run this program it show some error.
it means multiple argument are not allow in print .
Eg iii (check return type)
 <?php
$name = "Ravi ";
$ret = print $name;
//To test it returns or not
echo $ret;
?>

 Output: Ravi 
In the above example
declare a variable $name hold value=�ravi�.now we check the return type of print .
So (print $name )is store in a variable($ret) .
it will show $name value with return type=1.
Read more »

Saturday, June 17, 2017

Difference between and Variables in PHP

Difference between and Variables in PHP




$$var uses the value of the variable whose name is the value of $var.


It means $$var is known as refrence variable where as $var is normal variable.
It allows you to have a �variable�s variable� � the program can create the variable name the same way it can create any other string. .
Eg i
 <?php
$name="Rajeev";
$$name="Sanjeev";
echo $name."<br/>";
echo $$name."<br/>";
echo $Rajeev;

?>
 Output : Rajeev
Sanjeev
Sanjeev

In the above example
$name is just a variable with string value=�Rajeev�.
$$name is reference variable . $$name uses the value of the variable whose name is the value of $name.
echo $name print the value: rajeev
echo $$name print the value:Sanjeev value of this($name) variable is act as reference of second variable($$name).
echo $rajeev print the value :Sanjeev Here $rajeev is also act as reference variable.
Eg ii
 <?php
$x = "100";
$$x = 200;
echo $x."<br/>";
echo $$x."<br/>";
echo "$100";

?>
 Output : 100
200
200

In the above example
You first assign the value of a variable, ($x) as the name of another variable.
When you set $x to a value, it will replace that variable name with the value of the variable you provide.
variable $x hold value = 100.
$$x(reference variable) hold value = 200. now we want to print the value.
echo $x gives output:100
echo $$x gives output:200.
echo $100 gives value.200. because it also act as a reference variable for value = 200.
Eg iii
 <?php
$name="Rajeev";
${$name}="Sanjeev";
echo $name."<br/>";
echo ${$name}."<br/>";
echo "$Rajeev"."<br/>";
?>
 Output: Rajeev
Sanjeev
Sanjeev



Eg iv
 <?php
$name="Ravi";
${$name}="Ranjan";
${${$name}}="Rexx";
echo $name;
echo ${$name};
echo ${${$name}};
?>
 Output : Ravi
Ranjan
Rexx

In the above example
variable $name hold value =�ravi�
variable ${ $name } hold value =�Ranjan� // it also declare like ${Ravi}.
variable ${$ {$name} } hold value =�Rexx� // it act as �variable�s of variable of variable� reference.
echo $name show output:ravi
echo ${ $name } show output:Ranjan.
echo ${ $ {$name} } show output :Rexx
Read more »

Monday, April 10, 2017

Diablo III Reaper of Souls to cost Php 1 400

Diablo III Reaper of Souls to cost Php 1 400


Blizzard just recently released a survey to owners of Diablo III, which revealed some interesting information about the upcoming expansion pack.

According to this news article, the upcoming expansion pack of Diablo III will be coming in 2 flavors, just like the original version:

  • Standard Edition - includes the Reaper of Souls expansion only. To be priced at $29.99 (around Php1,400) 
  • Collectors Edition - includes the Reaper of Souls expansion, exclusive in-game content and other bonus items. To be priced at $49.99 (around Php2,200)
Interestingly the survey also asked participants of the survey to rate the features of the expansion pack in order of importance, as shown in the following screenshot:


Since most of us cant participate in the said survey Ive made a little poll of my own, and ask everyone what you think is the most important feature of the upcoming expansion pack.

What is the most important feature of Diablo III: Reaper of Souls are you most interested in?
 
 
 
 
 
 
 
 
  
pollcode.com free polls 

What do you guys think? Sound off your comments below! :)
Read more »