如果有人能帮我解决这个问题,我将不胜感激。我花了差不多三天时间试图解决这个问题,但我做不到。
我的session.php
档案
<?
class Session
{
var $time; //Time
var $url; //The page url
/* Class constructor */
function Session(){
// $this->time = time();
$this->startSession();
//$_SESSION['expire'] = $_SESSION['start'] + (1 * 60) ; // ending a session in 30 minutes from the starting time
}
function startSession(){
//global $database; //The database connection
session_start(); //Tell PHP to start the session
/* Set referrer page */
if(isset($_SESSION['url'])){
$this->referrer = $_SESSION['url'];
}else{
$this->referrer = "/";
}
/* Set current url */
$this->url = $_SESSION['url'] = $_SERVER['PHP_SELF'];
}
};
//-----------------------------------------
// Start new wession
//-----------------------------------------
$session = new Session;
?>
Localhost输出见下文:
time = time(); $this->startSession(); //$_SESSION['expire'] = $_SESSION['start'] + (1 * 60) ; // ending a session in 30 minutes from the starting time } function startSession(){ //global $database; //The database connection session_start(); //Tell PHP to start the session /* Set referrer page */ if(isset($_SESSION['url']) && $_SESSION['url'] != '/index.php'){ $this->referrer = $_SESSION['url']; }else{ $this->referrer = "/"; } /* Set current url */ $this->url = $_SESSION['url'] = $_SERVER['PHP_SELF']; } }; //----------------------------------------- // Start new wession //----------------------------------------- $session = new Session; ?> 1) ? 's':''; return count($items); }*/ $uniqCustomerId = $_SESSION['uCustomerId']; //dmWListTotalLeft(); $query = mysql_query("SELECT * FROM `wishlist` where `uniqCustomerId` = $uniqCustomerId"); //$num_rows = mysql_num_rows($query); if(mysql_num_rows($query) !=0) { return mysql_num_rows($query); }else{ return 0; } } //----------------------------------------- // Total items //----------------------------------------- function dmWListTotal() { if(!isset ( $_SESSION['dm_cartmj01'])){ $dm_cart = 0; }else{ $dm_cart = $_SESSION['dm_cartmj01']; } if (!$dm_cart) { //echo "Your Wishlist is empty"; $dm_cart = 0; return ''; } else { //echo "Your Wishlist"; // Parse the cart session variable $items = explode(',',$dm_cart); $s = (count($items) > 1) ? 's':''; return '
You have '.count($items).' item'.$s.' in your wishlist
'; } } // Back to catalogue //----------------------------------------- // Show List NEW //----------------------------------------- function dmWListShowNew() { // init $uniqCustomerId = $_SESSION['uCustomerId']; //dmWListTotalLeft(); $sn = 1; $result = mysql_query("SELECT * FROM `wishlist` where `uniqCustomerId` = $uniqCustomerId"); $num_rows = mysql_num_rows($result); // START if items exists in wishlist if($num_rows == 0){ $output[] = "
Your wishlist is empty
"; }else{ $output[] = '
'; while ($row = mysql_fetch_assoc($result)) { $id = $row['itemId']; $output[] = '
'; // ul start1 $result2 = mysql_query("SELECT * FROM `products` where prod_id ='".$id."LIMIT 1'"); while ($row2 = mysql_fetch_assoc($result2)) { $output[] = '
'.$sn.'
'; $output[] = '
答案 0 :(得分:1)
<?
?>
而不是在标签
下面使用<?php
?>
更新: 我用Hello()方法更新了类,它将返回larvel hello
<?php
class Session
{
var $time; //Time
var $url; //The page url
/* Class constructor */
function Session(){
// $this->time = time();
$this->startSession();
//$_SESSION['expire'] = $_SESSION['start'] + (1 * 60) ; // ending a session in 30 minutes from the starting time
}
function Hello(){
echo "laravel hello";
}
function startSession(){
//global $database; //The database connection
session_start(); //Tell PHP to start the session
/* Set referrer page */
if(isset($_SESSION['url'])){
$this->referrer = $_SESSION['url'];
}else{
$this->referrer = "/";
}
/* Set current url */
$this->url = $_SESSION['url'] = $_SERVER['PHP_SELF'];
}
};
//-----------------------------------------
// Start new wession
//-----------------------------------------
$session = new Session;
$session->Hello();
?>