Forum : php oop
Brief description  about Online courses   join in Online courses
View nishant  gaurav 's Profile

php oop

for the 1st problem i tried as
//oop1.html
<html>
<body>
<form method="post" action="oop.php">
enter the first number:
<input name="no" type="text"/><br/>
enter the second number:
<input name="not" type="text"/><br/>
<input type="submit"/>
</form>
</body>
</html>
and the file oop.php is

<html>
<body>
<?php
class p1{
var $one=$_POST["no"];
var $two=$_POST["not"];

function getone(){


echo $this->one ."<br/>";
}




function gettwo(){
echo $this->two ." <br/>";
}
}
$on=new p1();
$tw=new p1();
$on->getone();
$tw->gettwo();



?>
</body>
</html>
can you please tell me whats wrong with it?
thanking you,
nishant gaurav
Asked by nishant gaurav | Nov 14, 2010 |  Reply now
Replies (1)
View teacher siliconindia 's Profile
Hi Nishant Gaurav,

use the fallowing code for oop.php

<html>
<body>
<?php
error_reporting(E_ALL ^E_NOTICE);

class p1{

function getone($one1){

echo $this->one1=$one1 ."<br/>";

}


function gettwo($two2){

echo $this->two2=$two2." <br/>";

}

}
$one1=$_POST["no"];
$two2=$_POST["not"];

$on=new p1();
$tw=new p1();
$on->getone($one1);
$tw->gettwo($two2);

?>
</body>
</html>
Nov 18, 2010