isset() error in php

Asked

Viewed 24 times

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: inserir a descrição da imagem aqui

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?

  • Line 12 is the line : $i = date("Y") - $a;

  • 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.

  • This is the snippet of the html code I passed in php: <input type="number" placeholder="4 digits" name="year"/>

  • @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.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.