共享sensorforyou的最近浏览过的产品功能

07月 25th, 2008

很简单的一个功能,就是在产品内容页面放入一段代码,把当前的产品id放到cookie中,当检查到cookie中有相应的值时,就把他按自己的样子显示出来
1。在includes/modules/pages/product_info/header_php.php 中加入以下代码,以写cookie
if($_GET[’products_id’] != ”) {
if(!isset($_COOKIE[’product_history’]) ) {
$history_array = (int)$_GET[’products_id’];
zen_setcookie(’product_history’, $history_array, time()+60*60*24*30, ‘/’, ‘www.sensorforyou.com’);

} else {
$history_array = explode(’,',$_COOKIE[’product_history’]);
array_unshift($history_array,(int)$_GET[’products_id’]);
$history_array = array_unique($history_array);
if(count($history_array) > 6)
array_pop($history_array);
zen_setcookie(’product_history’, implode(’,',$history_array), time()+60*60*24*30, ‘/’, ‘www.sensorforyou.com’);

}

}
注意要自己把zen_setcookie函数的域名参数改为自己的域名 Read the rest of this entry »

入门:PHP编程“数组”的基础知识

07月 25th, 2008

关于数组:
PHP中的数组是复杂的,并且比许多其他高级语言中的数组更灵活。
数组array是一组有序的变量,其中每个变量被叫做一个元素。
数组可以被编号或者相关联,也就是数组的元素可以分别根据数字索引或文本化字符串来访问
PHP中,数组可以包含标量(整数,布尔,字符串,浮点数)或复合值(对象甚至其他数组),并且可以包含不同类型的值 Read the rest of this entry »