///<summary>
/// equiv of PHP's var dump for an object’s properties because i cbf writing all the properties out.
///</summary>
///<param name="info"></param>
private static string var_dump(object info)
{
StringBuilder sb = new StringBuilder();
Type t = info.GetType();
PropertyInfo[] props = t.GetProperties();
sb.AppendFormat("{0,-18} {1}", "Name", "Value");
你是使用 cakephp框架吗?
1、你先定义一个model 与表名对应:
class Hotel extends AppModel
{
var $name='Hotel';
}
2、写一个controllers :
var $name='Hotels';
var $ext=".html";
var $uses = array('Homeroom','Hotel','Wineshop');
var $helpers=array('Html','Javascript','Ajax','Form');
function hotels_name()
{
$hotel_name=$this->data['select']['hotel_name'];
$this->set('hotel_name',$hotel_name);
$this->set('hotel_name',$this->Homeroom->find('all', array('homeroom_id', 'hometype', 'menprice','firstprice'), 'homeroom_id DESC'));
}
3、页面得到:
<?php
var_dump($hotel_name);
?>
<?php foreach($hotel_name as $Hotel_name){?>