Submitted by 淡水河边 on 2008, June 28, 5:16 PM
include()时,如果被包含文件使用了return返回值,那么include()就直接返回该return的值。
PHP代码
- <?php
-
- return 'hello world';
- ?>
PHP代码
- <?php
-
- $str = include '1.php';
- echo "$str";
- ?>
利用这个特性可以方便地使用php文件来做配置。比如
PHP代码
- <?php
-
- return array(
- 'db'=>array(
- 'host' => 'localhost',
- 'user' => 'root',
- 'password' => 'root',
- 'name' => 'test',
- 'encoding' => 'utf8'
- )
- );
使用时只要 $config = include 'inc/config.php'; 避免了不必要的变量,节省内存.
另:
今天用editplus时,发现“函数列表”里空空的。原来是function前面有public等限定符。
把php的函数模板改动一下就认识了。
PHP代码
- ^[ \t]*(function|public|protected|private|static)[ \t].*\([^;]*$
Tags: include, editplus
网站|PHP学习 | 评论:0
| Trackbacks:0
| 阅读:70
Submitted by 淡水河边 on 2008, June 22, 8:19 PM
jQuery获取表单各元素的值及其AJAX应用.比较简单也是常用到的.
» 阅读全文
Tags: jquery
网页|前台相关 | 评论:0
| Trackbacks:0
| 阅读:154
Submitted by 淡水河边 on 2008, June 19, 8:42 PM
先贴代码
PHP代码
- <?php
-
-
-
-
- function url_parse()
- {
- if (!(isset($_SERVER['PATH_INFO']) && defined('PATH_INFO'))) {
- return;
- }
- $url = substr($_SERVER['PATH_INFO'], 1);
- $url = str_replace(array("'", '"', '.htm', '.html'), array('', '', '', ''), $url);
- $url = explode('/', $url);
- $param_count = count($url);
- for ($i = 0; $i < $param_count; $i += 2) {
- if (isset($url[$i + 1]) && !is_numeric($url[$i])) {
- $_GET[$url[$i]] = $url[$i + 1];
- }
- }
- unset($param_count, $url, $i);
- }
- ?>
说明:
www.yogool.cn/index.php/category/ajax 。(ajax后面可加.htm)这样,用$_GET['category']即可取出ajax.
再如 www.yogool.cn/index.php/category/ajax/page/2.htm,这样用$_GET['page']可取到2;它的页面相当于www.yogool.cn/index.php?category=ajax&page=2
淡水以前也写过,不过不是没写成函数,且要考虑到图片和css路径的问题.
原文:http://www.yogool.cn/index.php?controller=Default&action=ShowArticle&aid=10
Tags: path_info
网站|PHP学习 | 评论:0
| Trackbacks:0
| 阅读:149
Submitted by 淡水河边 on 2008, June 19, 8:30 PM
内容:
内容:
- jQuery特点
- CSS选择器用法
- jQuery集合
- jQuery集合操作
- 获取匹配元素的值
- DOM元素遍历
- 事件处理
- 安静加载运行
- 对象链串访问
- 疯狂链串(Crazy Chaining)
- Ajax用法
- 推荐了几个插件
Tags: jquery
网页|前台相关 | 评论:0
| Trackbacks:0
| 阅读:151
Submitted by 淡水河边 on 2008, June 17, 2:15 PM
留心处处出学问啊。这么简单的方法,为啥就没想到呢?
主动研究和被动学习的差别?
» 阅读全文
网站|PHP学习 | 评论:1
| Trackbacks:0
| 阅读:266
Submitted by 淡水河边 on 2008, June 6, 11:49 AM
1,用内置的prototype框架时,hide()和show()方法在ie下报错(object doesn't support this property or method),firefox3正常.
改用$('suggestions').style.display = none/''后解决问题。
2,我不习惯用prototype框架,我习惯了jquery。但是我又不想浪费现成的自动验证功能。
在<html:import type="js" file="Js.prototype" /> 等的最后边加上<html:import type="js" file="Js.Ajax.jquery" />。然后在页面的js块里,jQuery.noConflict();这样jquery就不在和prototype抢占$这个函数。jquery里用jQuery('#id')代替$('#id').
Tags: 框架
网站|PHP学习 | 评论:0
| Trackbacks:0
| 阅读:183