PHP ZCE mock test, interview preparation, daily lessons under chalk talk

Monday, May 14, 2012

Girlfriend's Name?

Read the following piece of code


<form action="welcome.php" method="post">
             Your Name <input type="text" name="fname"/>
             Your Girl Friend Name: <input type="text" name="fname" />
             <input type="submit"/>
</form>




The php code of the welcome.php file is as follows:

Welcome <?php echo $_POST['fname'];?> and <?php echo $_POST['fname'];?>!




What will be the output if you give your name as Jim and your girlfriend's name as Nancy?
a) Welcome Jim and Nancy!
b) Welcome Jim and Jim!
c) Welcome Nancy and Jim!
d) Welcome Nancy and Nancy!



Solution is d) Welcome Nancy and Nancy!
surprising! isn't it, after having your girlfriend's name, php ignored you...:D

1 comment: