0
I have the following code snippet:
<?php
$a = isset($_GET["ano"])?$_GET["ano"]:1900;
$i = date("Y") - $a;
echo "Você nasceu em $a e tem $i";
?>
Where the following errors are occurring:
The isset() '1900' value is not being displayed and the $i variable is not being recognized. How could I adjust these errors?
What is line 12?
– Sam
Line 12 is the line : $i = date("Y") - $a;
– Willian.Cruz
The error is not in the ISSET, probably the value you passed in the URL, which should contain the year, does not contain a numeric value and causes the error.
– Guilherme Nascimento
This is the snippet of the html code I passed in php: <input type="number" placeholder="4 digits" name="year"/>
– Willian.Cruz
@Willian.Repeat Cross, probably the value you passed in the URL, which should contain the year, does not contain a numeric value and causes the error. Which URL did you try to access? PS: the error has nothing to do with isset unless you have some other script before.
– Guilherme Nascimento