php smarty»ù±¾Ê¹ÓÃ
1.»ù±¾Àà
//smarty_config.php
<?php
define('TEMPLATE_DIR','templates/');
define('COMPILE_DIR','templates_c/');
define('CONFIG_DIR','configs/');
define('CACHE_DIR','cache/');
?>
//View.class.php
<?php
//ÅäÖÃÎļþ
require_once 'configs/smart_config.php';
//SmartyÀà
require('smarty/Smarty.class.php');
class View extends Smarty {
function SmartyFactory() {
$this->Smarty();
//Ä£°å·¾¶
$this->template_dir = TEMPLATE_DIR;
//±àÒëºóÎļþ
$this->compile_dir = COMPILE_DIR;
//ÅäÖÃÎļþ
$this->config_dir = CONFIG_DIR;
//»º´æÎļþ
$this->cache_dir = CACHE_DIR;
$this->debugging = true;
}
//ÖØÐ·â×°display ¸öÈËϰ¹ß¸Ä³Éshow
function show($name,$cacheId='') {
if($cacheId == '')
$this->display($name.'.htm');
else
$this->display($name.'.htm',$cacheId);
}
//ÖØÐ·â×°assign ϰ¹ßÓÃadd
function add($name,$value) {
$this->assign($name,$value);
}
}
?>
»ù±¾Ä¿Â¼Èç:
test
|-configs
|-templates
|-templates_c
|-cache
|-smarty --smarty lib
2.»ù±¾Ê¹ÓÃ
//index.php
<?php
require_once('View.php');
//Êý¾Ý²éѯ mysql_fetch_assoc() ·µ»ØÊý×é
//Êý¾Ý¿â²ã·â×°
//Èç:$User = new User();
//$Users = $User->paging('²ÎÊý');
$View = new View();
$View->add("users",$Users);
$View->show("index");
?>
//public.conf
[public]
public = public/
img = public/img/
css = public/css/
js = public/js/
//index.htm --ÔÚtemplatesÎļþ¼ÐÏ ¼ò¶Ì½éÉÜÏÂ
<html>
<!-- °üº¬meta.htmÎļþ-->
{include file="meta.htm"}
<!-- ÀûÓÃsmarty configÎļþ ¶¨Òå»ù±¾ÐÅÏ¢-->
{config_load file=public.conf section="public"}
<!-- ÂÔ -->
<table>
<tr>
<!-- {#img#} imgµÄ»ù±¾Â·¾¶ ¶ÔÓÚÒ»°ãÐ¡ÍøÕ¾µÄ×ö·¨ ÈçÓÐÊÇʹÓÃÁ˶þ¼¶ÓòÃûµÄ¾²Ì¬·þÎñÆ÷û±ØÒªÁË-->
<td><input type="image" src="{#img#}xxx.gif"/></td>
</tr>
Ïà¹ØÎĵµ£º
//´´½¨Îļþ¼Ð
function createdir($dir){
$edir = explode('/',$dir);
for($i=0;$i<count($edir);$i++)
{
$edirm = $edir[0];
for($ii=1;$ii<=$i;$ii++)
{
$edirm = $edirm.'/'.$edir[$ii];
}
if(file_exists($edirm) && is_dir($edirm))
{}
else
{
@mkdir ($edir ......
$_POST ±äÁ¿ÓÃÓÚÊÕ¼¯À´×Ô method="post" µÄ±íµ¥ÖеÄÖµ¡£
$_POST ±äÁ¿
$_POST ±äÁ¿ÊÇÒ»¸öÊý×飬ÄÚÈÝÊÇÓÉ HTTP POST ·½·¨·¢Ë͵ıäÁ¿Ãû³ÆºÍÖµ¡£
$_POST ±äÁ¿ÓÃÓÚÊÕ¼¯À´×Ô method="post" µÄ±íµ¥ÖеÄÖµ¡£´Ó´øÓÐ POST ·½·¨µÄ±íµ¥·¢Ë͵ÄÐÅÏ¢£¬¶ÔÈκÎÈ˶¼ÊDz»¿É¼ûµÄ£¨²»»áÏÔʾÔÚä¯ÀÀÆ÷µÄµØÖ·À¸£©£¬²¢ÇÒ¶Ô·¢ËÍÐÅÏ¢µÄÁ¿Ò²Ã»ÓÐÏÞÖ ......
php ʹÓÃÃüÁîÐÐ×Ô±äÁ¿
ÔÚÃüÁîÐÐÀïÊäÈë³ÌÐò²ÎÊýÀ´¸ü¸ÄÆäÔËÐз½Ê½ÊǺܳ£¼ûµÄ×ö·¨¡£ÄãÒ²¿ÉÒÔ¶ÔCLI³ÌÐòÕâÑù×ö¡£PHP
CLI´øÓÐÁ½¸öÌØÊâµÄ±äÁ¿£¬×¨ÃÅÓÃÀ´´ïµ½Õâ¸öÄ¿µÄ£ºÒ»¸öÊÇ$argv±äÁ¿£¬Ëüͨ¹ýÃüÁîÐаѴ«µÝ¸øPHP½Å±¾µÄ²ÎÊý±£´æÎªµ¥¶ÀµÄÊý×éÔªËØ£»ÁíÒ»¸ö
ÊÇ$argc±äÁ¿£¬ËüÓÃÀ´±£´æ$argvÊý×éÀïÔªËØµÄ¸öÊý¡£
ÓÃ ......
When I deploy php application on apache, some problem come out, and solved. Here's the tips and problems solved.
0.How could I deploy an apache server armed with php, mysql, perl, and phpMyAdmin on the fly?
You need a package bundled with all these tools, xampp shall meet you needs, you can ......
import java.io.IOException;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
public class DES {
private byte ......