Add an integer and string to produce integer in PHP

Description

The following code shows how to add an integer and string to produce integer.

Example


<?php/*  w w w .j  a  v a  2s.  com*/
 $number = "5"; // $number is a string
 echo $number;
 $sum = 15 + $number; // Add an integer and string to produce integer
 echo $sum;
 $sum = "twenty"; // Overwrite $sum with a string.
 echo $sum;
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Language Basic »




PHP Introduction
PHP Operators
PHP Statements
Variable
PHP Function Create
Exception
PHP Class Definition