Advertisements

This is correct code

Postby srvishnukumar » Thu Nov 19, 2009 1:31 pm

Offline
srvishnukumar
Posts: 1
Joined: Wed Nov 18, 2009 6:19 am
Hi Frnds,

Am New For PHP... Here i had create an php code about ADD TWO VALUES but i have been contain Error

Code is here
<?php
$a;
$b;
$num;
echo "Enter the First Value : ";
echo "Enter the Second Value : ";
$num = $a + $b;
echo "The Result is :"$num;
?>

If any mistake plz correct me

by sr_vishnukumar

ยป

Postby Arjun » Sat Jun 04, 2011 3:36 pm

Offline
Arjun
Posts: 5
Joined: Sat Jun 04, 2011 2:09 pm
i have seen your problem.
I dont understand that how you are getting the values of a and b

You must use textboxes in HTML for getting the values of a and b. If you want to make it static then do the following :

<?php
$a=4;
$b=5;
$num;
$num = $a + $b;
echo "The Result is :" . $num;
?>


No need to include this
echo "Enter the First Value : ";
echo "Enter the Second Value : ";

This is correct code

Postby swarndeep » Mon Sep 03, 2012 4:25 pm

Offline
swarndeep
Posts: 1
Joined: Mon Sep 03, 2012 4:21 pm
<?php
$a;
$b;
$num;
echo "Enter the First Value : ";
echo "Enter the Second Value : ";
$num = $a + $b;
echo "The Result is :"$num;
?>

you have miss the concadenation. echo "The Result is :."$num;
Swarndeep Poddar Visit My Blog