2016-09-28

Sep 28 Class Thread.

Post your answers to the September 28th class thread here.
Best, Chris
Post your answers to the September 28th class thread here. Best, Chris

-- Sep 28 Class Thread
<?php
    include 'some_file.php';
    session_start();
    if (isset($_REQUEST['set_time']))
    {
        $_SESSION['time'] = time();
    }
    if (isset($_REQUEST['name']))
    {
        $_SESSION['name'] = $_REQUEST['name'];
    }
    print_r($_SESSION);
    
    //sessions stored in xampp/tmp by default
    //contents of session file with the arguments set_time=y and name=adrian 
    //  time|i:1475095969;name|s:6:"adrian";
    
    //error messages received when:
    //some_file.php does not exist - 
    //Warning: include(some_file.php): failed to open stream: No such file
    //  or directory in C:\...\sessiontest.php on line 5
    //  Warning: include(): Failed opening 'some_file.php' for inclusion
    //  (include_path='...') in C:\...\sessiontest.php on line 5
    //  Array ( [time] => 1475096459 [name] => adrian ) 
    //some_file.php consists of a single space - 
    //no error messages
    //some_file.php consists of the five characters: <?php -
    //no error messages
    
    //echo phpinfo();
?>
(Edited: 2016-09-28)
<?php include 'some_file.php'; session_start(); if (isset($_REQUEST['set_time'])) { $_SESSION['time'] = time(); } if (isset($_REQUEST['name'])) { $_SESSION['name'] = $_REQUEST['name']; } print_r($_SESSION); //sessions stored in xampp/tmp by default //contents of session file with the arguments set_time=y and name=adrian // time|i:1475095969;name|s:6:"adrian"; //error messages received when: //some_file.php does not exist - //Warning: include(some_file.php): failed to open stream: No such file // or directory in C:\...\sessiontest.php on line 5 // Warning: include(): Failed opening 'some_file.php' for inclusion // (include_path='...') in C:\...\sessiontest.php on line 5 // Array ( [time] => 1475096459 [name] => adrian ) //some_file.php consists of a single space - //no error messages //some_file.php consists of the five characters: <?php - //no error messages //echo phpinfo(); ?>

-- Sep 28 Class Thread
<?php
    
	include('some_file.php');	
	session_start();
	error_reporting(-1); 
	ini_set('display_errors', 'On');
	if(!empty($_REQUEST['set_time']))
	{
		$_SESSION['time']=time();
		if(isset($_REQUEST['name']))
		{
			$_SESSION['name']=$_REQUEST['name'];
		}
	}
	print_r($_SESSION);
	$session_save=session_save_path();
	echo $session_save;
	
?>
 Error message when somefile_path does not exist
 Warning: include(some_file.php): failed to open stream: No such file or directory in C:\xampp\htdocs\hello.php on line 3
 Warning: include(): Failed opening 'some_file.php' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\hello.php on line 3
 contents of $_SESSION:
Array ( [arg] => abc [time] => 1475099393 [name] => vasudha )
 session file saved in :C:\xampp\tmp
 if some_file.php has a space
 Array ( [arg] => abc [time] => 1475099393 [name] => vasudha )
 C:\xampp\tmp
 if it has 5 characters
Array ( [arg] => abc [time] => 1475099393 [name] => vasudha )
 C:\xampp\tmp
(Edited: 2016-09-28)
<?php include('some_file.php'); session_start(); error_reporting(-1); ini_set('display_errors', 'On'); if(!empty($_REQUEST['set_time'])) { $_SESSION['time']=time(); if(isset($_REQUEST['name'])) { $_SESSION['name']=$_REQUEST['name']; } } print_r($_SESSION); $session_save=session_save_path(); echo $session_save; ?> Error message when somefile_path does not exist Warning: include(some_file.php): failed to open stream: No such file or directory in C:\xampp\htdocs\hello.php on line 3 Warning: include(): Failed opening 'some_file.php' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\hello.php on line 3 contents of $_SESSION: Array ( [arg] => abc [time] => 1475099393 [name] => vasudha ) session file saved in :C:\xampp\tmp if some_file.php has a space Array ( [arg] => abc [time] => 1475099393 [name] => vasudha ) C:\xampp\tmp if it has 5 characters Array ( [arg] => abc [time] => 1475099393 [name] => vasudha ) C:\xampp\tmp

-- Sep 28 Class Thread
<?php include 'some_file.php'; session_start(); if(isset($_REQUEST['set_time'])){ $_SESSION['time'] = time(); }
	if(isset($_REQUEST['name']))
	{
		$_SESSION['name'] = $_REQUEST['name'];
	}
phpinfo(); print_r($_SESSION); ?> <!-- Warning: include(some_file.php): failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/dashboard/practice.php on line 2
Warning: include(): Failed opening 'some_file.php' for inclusion (include_path='.:/Applications/XAMPP/xamppfiles/lib/php') in /Applications/XAMPP/xamppfiles/htdocs/dashboard/practice.php on line 2 -->
<?php include 'some_file.php'; session_start(); if(isset($_REQUEST['set_time'])){ $_SESSION['time'] = time(); } if(isset($_REQUEST['name'])) { $_SESSION['name'] = $_REQUEST['name']; } phpinfo(); print_r($_SESSION); ?> <!-- Warning: include(some_file.php): failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/dashboard/practice.php on line 2 Warning: include(): Failed opening 'some_file.php' for inclusion (include_path='.:/Applications/XAMPP/xamppfiles/lib/php') in /Applications/XAMPP/xamppfiles/htdocs/dashboard/practice.php on line 2 -->

-- Sep 28 Class Thread
<?php
    include 'some_file.php';
    error_reporting(-1);
    ini_set('display_errors', 'On');
    session_start();
    if(isset($_REQUEST['set_time']))
    {
        $_SESSION['time'] = time();
        if(isset($_REQUEST['name']))
        {
            $_SESSION['name'] = $_REQUEST['name'];
        }
    }
    print_r($_SESSION);
    //phpinfo();
    //C:\xampp\tmp
    /*No some_file.php:
      Warning: include(some_file.php): failed to open stream: No such file or directory in C:\xampp\htdocs\session.php on line 2
      Warning: include(): Failed opening 'some_file.php' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\session.php on line 2
      One space some_file.php:
      No error.
      Five character some_file.php
      No error
    */
    
?>
<?php include 'some_file.php'; error_reporting(-1); ini_set('display_errors', 'On'); session_start(); if(isset($_REQUEST['set_time'])) { $_SESSION['time'] = time(); if(isset($_REQUEST['name'])) { $_SESSION['name'] = $_REQUEST['name']; } } print_r($_SESSION); //phpinfo(); //C:\xampp\tmp /*No some_file.php: Warning: include(some_file.php): failed to open stream: No such file or directory in C:\xampp\htdocs\session.php on line 2 Warning: include(): Failed opening 'some_file.php' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\session.php on line 2 One space some_file.php: No error. Five character some_file.php No error */ ?>
2016-09-29

-- Sep 28 Class Thread
<?php include "some_file.php"; session_start();
 if(!(isset($_REQUEST['set_time']))){
  $_SESSION['set_time'] = date("h:i:sa");
  if(!(isset($_REQUEST['name']))){
   $_SESSION['name'] = "Anthony";
  }
}
print_r($_SESSION); ?>
/*find does not exits:
Warning: include(some_file.php): failed to open stream: No such file or directory in /var/www/newSite/public_html/Sept28.php on line 2
Warning: include(): Failed opening 'some_file.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/newSite/public_html/Sept28.php on line 2 /opt/lampp/temp/Array ( [set_time] => 12:34:12pm [name] => Anthony )
one space: no error <?php: no error
(Edited: 2016-09-29)
<?php include "some_file.php"; session_start(); if(!(isset($_REQUEST['set_time']))){ $_SESSION['set_time'] = date("h:i:sa"); if(!(isset($_REQUEST['name']))){ $_SESSION['name'] = "Anthony"; } } print_r($_SESSION); ?> /*find does not exits: Warning: include(some_file.php): failed to open stream: No such file or directory in /var/www/newSite/public_html/Sept28.php on line 2 Warning: include(): Failed opening 'some_file.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/newSite/public_html/Sept28.php on line 2 /opt/lampp/temp/Array ( [set_time] => 12:34:12pm [name] => Anthony ) one space: no error <?php: no error
2016-10-03

-- Sep 28 Class Thread
People should do the ini_set and error_reporting command before everything else to properly do this experiment.
People should do the ini_set and error_reporting command before everything else to properly do this experiment.
2016-10-11

-- Sep 28 Class Thread
<?php
 error_reporting(-1); ini_set('display_errors', 'On');
 include('abc.php');
 session_start();
 if(!empty($_REQUEST['set_time']))
 {
 	$_SESSION['time']=time();
 	if(isset($_REQUEST['name']))
 	{
		 $_SESSION['name']=$_REQUEST['name'];
	 }
 }
 echo session_save_path();
 print_r($_SESSION);
?>
Even though it shows error for the include failure(when abc.php does not exist), it is displaying session variables. I checked in the directory where session variables are stored. It saves the session variables in a serialized file in both cases where we give single space as well as when we give "<?php". In the non-existent file scenario, it does not store the serialized session variables in any file. But, peculiarly I was able to get the session variables displayed using $_SESSION.
Please let us know what is the expected result.
(Edited: 2016-10-11)
<?php error_reporting(-1); ini_set('display_errors', 'On'); include('abc.php'); session_start(); if(!empty($_REQUEST['set_time'])) { $_SESSION['time']=time(); if(isset($_REQUEST['name'])) { $_SESSION['name']=$_REQUEST['name']; } } echo session_save_path(); print_r($_SESSION); ?> Even though it shows error for the include failure(when abc.php does not exist), it is displaying session variables. I checked in the directory where session variables are stored. It saves the session variables in a serialized file in both cases where we give single space as well as when we give "<?php". In the non-existent file scenario, it does not store the serialized session variables in any file. But, peculiarly I was able to get the session variables displayed using $_SESSION. Please let us know what is the expected result.
X