PHP - Check if the variable is set and different than Null with isset

0 votes
591 views
added Aug 13, 2019 in PHP by LC Marshal Captain (25,790 points)
isset — To check if the variable is declared and different than NULL
<?php
if(isset($_POST['name'])){ 
    // anything here
}
?>

 

3 Responses

0 votes
responded Aug 13, 2019 by LC Marshal Captain (25,790 points)
<?php
  if (isset($_GET["page"])) {
    $current_page = trim($_GET["page"]);
  } else {
    $current_page = 1;
  }
?>

 

0 votes
responded Aug 16, 2019 by lcjr First Warrant Officer (11,990 points)
if (isset($_GET["combine"])){
      $txt = $_GET["combine"];
} else {
      $txt = '';
}

 

0 votes
responded Aug 16, 2019 by lcjr First Warrant Officer (11,990 points)
<?php
if(isset($_GET["reqDate"])){
  $currentDate = date("l, j M Y", strtotime($_GET["reqDate"]));
  $nextDay = date("Y-m-d", strtotime($_GET["reqDate"]. " + 1 days")); //date($_GET['reqDate'], strtotime("+ 1 day"));
  $prevDay = date("Y-m-d", strtotime($_GET["reqDate"]. " - 1 days"));
}else if(isset($_GET["start_date"]["value"]["date"]) && !empty($_GET["start_date"]["value"]["date"])){
  $searchDate = $_GET["start_date"]["value"]["date"];
  $currentDate = date("l, j M Y", strtotime($searchDate));
  $nextDay = date("Y-m-d", strtotime($searchDate. " + 1 days")); //date($_GET['reqDate'], strtotime("+ 1 day"));
  $prevDay = date("Y-m-d", strtotime($searchDate. " - 1 days"));
}else{
  $currentDate = date('Y-m-d');
  $currentDate = date("l, j M Y", strtotime($currentDate));
  $nextDay = date("Y-m-d", strtotime($currentDate. " + 1 days"));
  $prevDay = date("Y-m-d", strtotime($currentDate. " - 1 days"));
}
?>

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...