[PHP]Smarty的使用
<?php
define('SMARTY_TMP_DIR','C:/php5/Smarty-2.6.13/');
define('SMARTY_DIR','C:/php5/Smarty-2.6.13/libs/'); //SMARTY_DIR ->smarty keyword,must be defined as libs dectory
require_once(SMARTY_DIR.'Smarty.class.php');
//建立一个smarty对象
$smarty = new Smarty;
$smarty->template_dir = SMARTY_TMP_DIR.'templates/';
$smarty->compile_dir = SMARTY_TMP_DIR.'templates_c/';
$smarty->config_dir = SMARTY_TMP_DIR.'configs/';
$smarty->cache_dir = SMARTY_TMP_DIR.'cache/';
//$smarty->left_delimiter = '{/';
//$smarty->right_delimiter = '/}';
//----------simple show example------------
//$smarty->assign('name','Porky');
//$smarty->display('smarty_test.tpl');
?>
相关文档:
强大而且免费的 zend studio 首当其冲,可惜本人机器配置不高,运行起来十分吃力,用没两次太受罪就放弃了。
PHPEdit,短小精悍,可限时试用,感觉一般。
PHPDesigner 正在用,还是可以一试,网上的注册机出的也相当及时。 0.0
纯文本编辑 Editplus 还是常备工具。 ......
PHP的数据类型的转换有两种方法可以办到:直接输入目标的数据类型和通过settype函数实现。
PHP数据转换成整数
Float型数据转换成int型
Float型转换成int型,小数点后的数将被舍弃。如果float数超贵超过了整型的取值范围,那么结果可能是0或者是整形的最小负数。
例如:
<?php
$php = 1.59;
echo (int)$php.&rdquo ......
PHP用户登录模块实现
项目包含的功能脚本:
login.php//登录
reg.php//注册用户
user_add.php//注册校验脚本
user_login_check.php//登录校验脚本
image.php//验证码图片生成脚本
流程:
设计数据库:
包含用户uid,用户名,密码,昵称,性别,邮箱,注册时间
sql语句如下
create table users (uid bigint(20) ......
1. 安装php5.1以上的版本,有支持pdo!为了使你的环境能提供对pdo的支持!在php.ini文件加入以下:
extension=php_pdo.dll
extension=php_pdo_mysql.dll
extension=php_pdo_mssql.dll(支持mssql数据库)
2. 以下为PH中PDO的具体使用
<?php
$dsn = 'mysql:dbname=MyDbName;host=localhost';
$user = 'root';
......
1. 数据库中已创建存储过程user_logon_check, PHP调用示例如下,
<?php
$dsn = 'mssql:dbname=MyDbName;host=localhost';
$user = 'sa';
$password = '666666';
try {
$dbCon = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
print 'Connection failed: '.$e->getMessage();
......