Answers for "startsession php"

PHP
4

php string starts with

//php check if first four characters of a string = http
substr( $http, 0, 4 ) === "http";
//php check if first five characters of a string = https
substr( $https, 0, 5 ) === "https";
Posted by: Guest on September-01-2020
7

php string starts with

function stringStartsWith($haystack,$needle,$case=true) {
    if ($case){
        return strpos($haystack, $needle, 0) === 0;
    }
    return stripos($haystack, $needle, 0) === 0;
}

function stringEndsWith($haystack,$needle,$case=true) {
    $expectedPosition = strlen($haystack) - strlen($needle);
    if ($case){
        return strrpos($haystack, $needle, 0) === $expectedPosition;
    }
    return strripos($haystack, $needle, 0) === $expectedPosition;
}
echo stringStartsWith("Hello World","Hell"); // true
echo stringEndsWith("Hello World","World"); // true
Posted by: Guest on August-06-2019
3

create session in php

<?php 
  // Start the session
  session_start();

  // Set session variables
  $_SESSION["color"]= "blue";
  $_SESSION["animal"]= "dog";
  echo "The session variable are set up.";
?>
Posted by: Guest on June-16-2020
-1

session start php

<?php
// This sends a persistent cookie that lasts a day.
session_start([
    'cookie_lifetime' => 86400,
]);
?>
Posted by: Guest on April-17-2020

Browse Popular Code Answers by Language