Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.1 kB
3
Indexable
Never
<?php
    class person{
        public $fname;
        public $lname;
        function __construct($fname ,$lname){
            $this->fname = $fname;
            $this->lname = $lname;
        }
        function fullName(){
            return $this->fname .' ' .$this->lname;
        }
    }
    if($_SERVER['REQUEST_METHOD']==='POST'){
        $fname = $_POST['fname'];
        $lname = $_POST['lname'];
        $result = new person($fname , $lname);
    }
echo 'Full Name : ' . $result->fullName();
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form action="./index.php" method="post">
        <div>
            <label for="fname">First Name</label>
            <input type="text" name="fname" id="fname">
        </div>
        <div>
            <label for="lname">First Name</label>
            <input type="text" name="lname" id="lname">
        </div>
        <button type="submit">Save</button>
    </form>
</body>
</html>