当前位置: 编程技术>php
本页文章导读:
▪php压缩多个CSS为一个css的代码并缓存
代码如下: <?php /* Compress multiple CSS files into one and cache for an hour. Use the same code for Javascript, but replace below "text/css" with "text/javascript" and of course make sure you include .js files instead of .css ones. */ ob_sta.........
▪flash用php连接数据库的代码
php代码: 代码如下: /* /flashservices/services/Catalog.php */ class Catalog { var $products_array = array(); // Constructor: Contains the list of methods available to the gateway function Catalog() { $this->methodTa.........
▪php中用数组的方法设置cookies
代码如下: <?php function set_cronology($name,$value,$duration=7){ $duration=time()+(3600*24*$duration); $max_stored_values=5; if(isset($_COOKIE[$name])){ .........
[1]php压缩多个CSS为一个css的代码并缓存
来源: 互联网 发布时间: 2013-11-30
代码如下:
<?php
/*
Compress multiple CSS files into one and cache for an hour.
Use the same code for Javascript, but replace below "text/css" with "text/javascript" and of course make sure you include .js files instead of .css ones.
*/
ob_start("ob_gzhandler");
header("Content-type: text/css; charset: UTF-8");
header("Expires: ".gmdate("D, d M Y H:i:s", time() + 60*60)." GMT");
include('somefile.css');
echo "\n\n";
include('anotherfile.css');
echo "\n\n";
ob_flush();
[2]flash用php连接数据库的代码
来源: 互联网 发布时间: 2013-11-30
php代码:
/* /flashservices/services/Catalog.php */
class Catalog {
var $products_array = array();
// Constructor: Contains the list of methods available to the gateway
function Catalog() {
$this->methodTable = array (
"getProducts" => array (
"description" => "Get list of products",
"access" => "remote",
"arguments" => "" // arguments could be optional, not tested
)
); // end methodTable
}
function getProducts() {
// your code goes here
return $this->products_array;
}
}
actionscript代码:
#include "NetServices.as"
NetServices.setDefaultGatewayUrl("http://yourserver.com/flashservices/gateway.php");
gw = NetServices.createGatewayConnection();
CatalogREMOTE = gw.getService("Catalog", this);
CatalogREMOTE.getProducts();
getProducts_Result = function(result) {
_root.products_results = result;
}
代码如下:
/* /flashservices/services/Catalog.php */
class Catalog {
var $products_array = array();
// Constructor: Contains the list of methods available to the gateway
function Catalog() {
$this->methodTable = array (
"getProducts" => array (
"description" => "Get list of products",
"access" => "remote",
"arguments" => "" // arguments could be optional, not tested
)
); // end methodTable
}
function getProducts() {
// your code goes here
return $this->products_array;
}
}
actionscript代码:
代码如下:
#include "NetServices.as"
NetServices.setDefaultGatewayUrl("http://yourserver.com/flashservices/gateway.php");
gw = NetServices.createGatewayConnection();
CatalogREMOTE = gw.getService("Catalog", this);
CatalogREMOTE.getProducts();
getProducts_Result = function(result) {
_root.products_results = result;
}
[3]php中用数组的方法设置cookies
来源: 互联网 发布时间: 2013-11-30
代码如下:
<?php
function set_cronology($name,$value,$duration=7){
$duration=time()+(3600*24*$duration);
$max_stored_values=5;
if(isset($_COOKIE[$name])){
foreach($_COOKIE[$name] as $prop_crono=>$val_crono){
if($val_crono==$value)
return;
}
if($prop_crono<$max_stored_values)
setcookie($name.'['.($prop_crono+1).']',$value,$duration);
else{
array_shift($_COOKIE[$name]);
setcookie("$name[$max_stored_values]",$value,$duration);
}
}else
setcookie($name.'[0]',$value,$duration);
return;
}
?>
最新技术文章: