如何用动态html在php中显示Session值?

如何用动态html在php中显示Session值?

问题描述:

<?php                            
       session_start();
       echo "<b>Start Date:</b>$_SESSION['Date']<br />";
       echo "<b>Venue:</b>$_SESSION['address']<br />";
       echo "<b>Church Name: </b>$_SESSION['ChurchLead']<br />";
       echo "<b>Course Type </b>$_SESSION['coursename']<br />";
       echo "<b>Participants: </b>$_POST['NumbPart']<br />";
       echo "<b> Latitude: </b>$_SESSION['lat']<br />";
       echo "<b> Longitude: </b>$_SESSION['long']<br />";
?>

Is this a correct way of displaying Session values in php? I am getting blank values.

 &lt;?php 
 session_start(); 
 echo“&lt; b&gt;开始日期:  &lt; / b&gt; $ _ SESSION ['日期']&lt; br /&gt;“; 
 echo”&lt; b&gt;地点:&lt; / b&gt; $ _ SESSION ['地址']&lt; br /&gt;“;  
 echo“&lt; b&gt;教会名称:&lt; / b&gt; $ _ SESSION ['ChurchLead']&lt; br /&gt;”; 
 echo“&lt; b&gt;课程类型&lt; / b&gt; $ _ SESSION ['  coursename']&lt; br /&gt;“; 
 echo”&lt; b&gt;参与者:&lt; / b&gt; $ _ POST ['NumbPart']&lt; br /&gt;“; 
 echo”&lt; b&gt;纬度 :&lt; / b&gt; $ _ SESSION ['lat']&lt; br /&gt;“; 
 echo”&lt; b&gt;经度:&lt; / b&gt; $ _ SESSION ['long']&lt; br /&gt;“  ; 
?&gt; 
  code>  pre> 
 
 

这是在php中显示会话值的正确方法吗? 我得到空白值。 p> div>

try this ,this is not better????? simple & easy read

<?php
   session_start();
?>
   <b>Start Date:</b><?=$_SESSION['Date'];?><br />
   <b>Venue:</b><?=$_SESSION['address'];?><br />
   <b>Church Name: </b><?=$_SESSION['ChurchLead'];?><br />
   <b>Course Type </b><?=$_SESSION['coursename'];?><br />
   <b>Participants: </b><?=$_POST['NumbPart'];?><br />
   <b> Latitude: </b><?=$_SESSION['lat'];?><br />
   <b> Longitude: </b><?=$_SESSION['long'];?><br />

To display the value from an array like that as string sub, you need to use {} around it in the string. For example:

echo "<b> Latitude: </b>$_SESSION['lat']<br />";

becomes

echo "<b> Latitude: </b>{$_SESSION['lat']}<br />";

This applies to instances where you are trying to access an array member, or accessing an object member (such as myObj->foo)

NOTE: I am operating under the assumption that your session array is completely valid.

First, change all lines to:

  echo "<b>MyVar:</b>".$_SESSION['myVar']."<br />";

Now, unless you have set the variable $_SESSION['MyVar'], you'll get blank output.