Normal year and leap year calculator

There will be an error message when entering for the first time, and it will disappear when you click the button.-PHP Chinese Network Q&A
There will be an error message when entering for the first time, and it will disappear when you click the button.
红红火火恍恍惚惚
红红火火恍恍惚惚 2019-10-08 00:08:23
0
7
1293


Normal year and leap year calculator





]PS2RRFF5669X7~3S7N}XRR.pngCU}AW~B7NU4HAI$ZL_H%M5R.png

$num1=$_GET['num1'];
if(!is_numeric($num1))
{echo 'Please enter the year correctly';
exit;}
if($num1%4 ==0 and $num1 0!==0 or $num1@0==0)
{echo $num1.

红红火火恍恍惚惚
红红火火恍恍惚惚

reply all (2)
海风

$_GET['num1'] does not exist when you first enter. It will be an error to assign a non-existent value to a variable, so give $num1 an initial value, such as: $num1 = isset($_GET[' num1']) ? $_GET['num1'] : 2019;

If you don't want the sentence "2019 is a normal year" to appear as soon as you refresh, modify the program as follows:

if (!empty($_GET['num1'])){

$num1=$_GET['num1'];

if(!i

  • reply Okay, thank you, boss.
    红红火火恍恍惚惚 author 2019-10-09 22:41:12
  • reply Why does isset report an error and empty does not?
    红红火火恍恍惚惚 author 2019-10-09 23:07:47
  • reply Boss, I just tried it and the conclusion is that when num1 is not empty, execute $num1=$_GET['num1']; If num1 is empty, the code within the curly brackets will not be executed. Is my conclusion correct or wrong?
    红红火火恍恍惚惚 author 2019-10-09 23:17:50
  • reply Check the manual. The empty function determines whether the parameter is empty. If the parameter is empty, the empty function returns true. Therefore, if num1 is empty, empty('num1') returns true, !empty('num1') returns false, so the code within the curly brackets will not be executed.
    海风 author 2019-10-10 09:22:57
卢小强

You can print out the value of $num1 when entering for the first time. I guess it is NULL. NULL cannot be used as an operation.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!