Tutorials Point, posted on 28th Nov, 2017

PHP Function date_date_set()

<?php
   $dateSrc = '2005-04-19 12:50 GMT';
   $dateTime = date_create( $dateSrc);;
   # Now set a new date using date_date_set();
   date_date_set( $dateTime, 2000, 12, 12);
   
   echo "New Formatted date is ". $dateTime->format("Y-m-d\TH:i:s\Z");
   echo "<br />";

   # Using second function.
   $dateTime = new DateTime($dateSrc);
   $dateTime->setDate( 1999, 10, 12);
   
   echo "New Formatted date is ". $dateTime->format("Y-m-d\TH:i:s\Z");
?>

Tutorials Point, posted on 27th Nov, 2017

usort() php program

<?php
   function cmp_function($a, $b) {
      if ($a == $b) return 0;
      return ($a > $b) ? -1 : 1;
   }
   
   $fruits = array("d"=>"lemon", "a"=>"orange", "b"=>"banana" );
   usort($fruits, "cmp_function");
   
   print_r($fruits);
?> 

Tutorials Point, posted on 27th Nov, 2017

Function array_uintersect_uassoc() php program

<?php
   $input1 = array("a"=>"green", "b"=>"brown", "c"=>"blue", "red");
   $input2 = array("a"=>"GREEN", "B"=>"brown", "yellow", "red");
   
   print_r(array_uintersect_uassoc($input1, $input2, "strcasecmp", "strcasecmp"));
?> 

Tutorials Point, posted on 27th Nov, 2017

PHP Function array_merge()

<?php
   $input = array("a"=>"Horse","b"=>"Cat","c"=>"Dog");
   $input1 = array("d"=>"Cow","a"=>"Cat","e"=>"elephant");
   
   print_r(array_merge($input,$input1));
?> 

Tutorials Point, posted on 27th Nov, 2017

PHP preg_quote() program

<?php
   $keywords = '$40 for a g3/400';
   $keywords = preg_quote($keywords, '/');
   
   echo $keywords;
?>

Tutorials Point, posted on 13th Nov, 2017

Php Multiple Arrays

<?php
   function call_back_func($v1, $v2) {
      if ($v1 === $v2) {
         return "equal";
      }
      return "different";
   }
   
   $array1 = array(1, 2, 3, 4);
   $array2 = array(10, 2, 30, 4);
   $b = array_map("call_back_func", $array1, $array2);
   
   print_r($b);

?>

Tutorials Point, posted on 6th Nov, 2017

PHP Function Str Ireplace

<?php
   $input = array("tutorials","point","simply","easy","learning");
   print_r(str_ireplace("simply","tutorials",$input,$i)); // Case-insensitive
   
   echo "<br>" . "Replacements: $i";  
?>

Tutorials Point, posted on 6th Nov, 2017

PHP Function chr split

<?php
   $str = "tutorialspoint";
   
   echo chunk_split($str,1,".");
?>

Tutorials Point, posted on 6th Nov, 2017

PHP Function trigger_error()

<?php
 if ($test<10) {
    trigger_error("Number cannot be less than 10");
}
?>

Tutorials Point, posted on 6th Nov, 2017

PHP Login Page

<?php
   ob_start();
   session_start();
?>

<?
   // error_reporting(E_ALL);
   // ini_set("display_errors", 1);
?>

<html lang = "en">
   
   <head>
      <title>Tutorialspoint.com</title>
      <link href = "css/bootstrap.min.css" rel = "stylesheet">
      
      <style>
         body {
            padding-top: 40px;
            padding-bottom: 40px;
            background-color: #ADABAB;
         }
         
         .form-signin {
            max-width: 330px;
            padding: 15px;
            margin: 0 auto;
            color: #017572;
         }
         
         .form-signin .form-signin-heading,
         .form-signin .checkbox {
            margin-bottom: 10px;
         }
         
         .form-signin .checkbox {
            font-weight: normal;
         }
         
         .form-signin .form-control {
            position: relative;
            height: auto;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
            padding: 10px;
            font-size: 16px;
         }
         
         .form-signin .form-control:focus {
            z-index: 2;
         }
         
         .form-signin input[type="email"] {
            margin-bottom: -1px;
            border-bottom-right-radius: 0;
            border-bottom-left-radius: 0;
            border-color:#017572;
         }
         
         .form-signin input[type="password"] {
            margin-bottom: 10px;
            border-top-left-radius: 0;
            border-top-right-radius: 0;
            border-color:#017572;
         }
         
         h2{
            text-align: center;
            color: #017572;
         }
      </style>
      
   </head>
	
   <body>
      
      <h2>Enter Username and Password</h2> 
      <div class = "container form-signin">
         
         <?php
            $msg = '';
            
            if (isset($_POST['login']) && !empty($_POST['username']) 
               && !empty($_POST['password'])) {
				
               if ($_POST['username'] == 'tutorialspoint' && 
                  $_POST['password'] == '1234') {
                  $_SESSION['valid'] = true;
                  $_SESSION['timeout'] = time();
                  $_SESSION['username'] = 'tutorialspoint';
                  
                  echo 'You have entered valid use name and password';
               }else {
                  $msg = 'Wrong username or password';
               }
            }
         ?>
      </div> <!-- /container -->
      
      <div class = "container">
      
         <form class = "form-signin" role = "form" 
            action = "<?php echo htmlspecialchars($_SERVER['PHP_SELF']); 
            ?>" method = "post">
            <h4 class = "form-signin-heading"><?php echo $msg; ?></h4>
            <input type = "text" class = "form-control" 
               name = "username" placeholder = "username = tutorialspoint" 
               required autofocus></br>
            <input type = "password" class = "form-control"
               name = "password" placeholder = "password = 1234" required>
            <button class = "btn btn-lg btn-primary btn-block" type = "submit" 
               name = "login">Login</button>
         </form>
			
         Click here to clean <a href = "logout.php" tite = "Logout">Session.
         
      </div> 
      
   </body>
</html>

1 2 3 4 5 6 7 ... 32 Next
Advertisements
Loading...