Login
网站首页 > 文章中心 > 其它

php响应式网址导航z

作者:小编 更新时间:2023-08-01 09:16:24 浏览量:318人看过

使用$_POST['参数名']处理post方法提交的参数,$_GET['参数名']处理get方法参数.

eg:

php

$name = $_GET['name'];

$pwd = $_GET['pwd'];

php响应式网址导航z-图1

do something;

如果url 为: index.html

$name = $_POST['name'];

$pwd = $_POST['pwd'];

如果只是处理如何要跳转到其他页面,可以用header("Location: 文件名");

如果是网页和php混合,在需要使用?php php语句;?处理就行;使用echo可以输出一些值到网页中.

linux下WebServer 怎么实现PHP动态网页响应!

php响应式网址导航z-图2

你直接去自己读 http 服务器的接口相关代码吧.

推荐个小型的 http 服务器程序

不过现在 cgi 方式是通用的,apache 的 so 方式调用貌似需要 php 这边代码的支持,也就是 apache 有 so 代码接口,php 根据这个接口做的扩展式模块.

这种方式也就两种办法,要么你的 httpd 服务器自己实现 apache 的模块接口函数,要么就去改写 php 的代码,给自己的 httpd 制作一个对应的模块功能.

当然还一个办法,那就是干脆集成 php 到你的服务器代码里.不过注意你的程序协议.php 虽然不是 gpl 的,用的是他自己的 PHP lic ,类似 BSD 但貌似不是 copyleft .

做个网站(php的),用许多的页面有相同的部分,如导航条之类的,想做个模板,问下怎么做,怎么加载?

可以在php中先:

include($tpl-template('moban.html'));

然后再再php中加载个Template.php 就可以了.

Template.php 代码如下:

class Template

{

public $templateDir = 'templates';

public $leftTag = '{';

public $rightTag = '}';

public $compileDir = 'cache';

public $compiledFileExt = '.TemplateCompiled.php';

public $caching = false;

public $cacheDir = 'cache';

public $cacheDirLevels = 0; //缓存目录层次

public $cacheFileExt = '.TemplateCache.php';

public $cacheID;

public $forceCompile = false;

public $lang=array();

private $cacheFile; //缓存文件,在_saveCache()中使用

private $realCacheID; //通过计算得出的缓存ID

public function __construct($arrConfig = array())

foreach ($arrConfig as $key=$val) {

$this-$key = $val;

}

if ($this-cacheDirLevelsself::MAX_CACHE_DIR_LEVELS) {

$this-cacheDirLevels=self::MAX_CACHE_DIR_LEVELS;

/**

* 判断缓存文件是否有效

*

* @param string $file

* @param string $cacheID

* @return boolean

*/

public function cached($file='',$cacheID='')

$file=$this-getTemplateFile($file);

$this-cacheID=$cacheID;

$cachefile=$this-getCacheFileName($file,$cacheID);

if ($this-caching is_file($cachefile) (filemtime($cachefile)+$this-cacheLifeTime)time()) {

return true;

} else {

return false;

* 返回模板文件完整路径

* @return string

php响应式网址导航z-图3

private function getTemplateFile($file='')

if (!strlen($file)) {

$file=App::$controller.'_'.App::$action.$this-templateFileExt;

return $file;

* 获取缓存文件完整路径

private function getCacheFileName($file,$cacheID)

if (!strlen($this-realCacheID)) {

$this-realCacheID=$cacheID!=''?$cacheID:$_SERVER['SCRIPT_NAME'].$_SERVER['QUERY_STRING'];

$this-realCacheID.=$this-templateDir.$file.APP_NAME;

* 获取缓存目录层次

$levels=array();

for ($i=0; $i$this-cacheDirLevels; $i++) {

return !count($levels) ? '' : '/'.implode('/',$levels);

* 在$this-compile()中替换$foo.var为数组格式$foo['var']

private function compile_replace($str)

return $this-leftTag.$str.$this-rightTag;

* 编译模板文件

private function compile($file='')

$fullTplPath=$this-templateDir.'/'.$file;

if ($this-forceCompile || !is_file($compiledFile) || filemtime($compiledFile)=filemtime($fullTplPath)) {

$content=file_get_contents($fullTplPath);

$leftTag=preg_quote($this-leftTag);

$rightTag=preg_quote($this-rightTag);

$search=array(

'/'.$leftTag.'include ([\w\.\/-]+)'.$rightTag.'/i', //导入子模板

'/'.$leftTag.'(\$[a-z_]\w*)\.(\w+)'.$rightTag.'/i', //将模板标签{$foo.var}修改为数组格式{$foo['var']}

'/'.$leftTag.'(.+?\$[a-z_]\w*\.\w+.*?)'.$rightTag.'/ie', //将模板标签中的$foo.var修改为数组格式$foo['var']

'/'.$leftTag.'(else if|elseif) (.*?)'.$rightTag.'/i',

'/'.$leftTag.'for (.*?)'.$rightTag.'/i',

'/'.$leftTag.'while (.*?)'.$rightTag.'/i',

'/'.$leftTag.'(loop|foreach) (.*?) as (.*?)'.$rightTag.'/i',

'/'.$leftTag.'if (.*?)'.$rightTag.'/i',

'/'.$leftTag.'else'.$rightTag.'/i',

'/'.$leftTag."(eval) (.*?)".$rightTag.'/is',

'/'.$leftTag.'\/(if|for|loop|foreach|while)'.$rightTag.'/i',

'/'.$leftTag.'((( *(\+\+|--) *)*?(([_a-zA-Z][\w]*\(.*?\))|\$((\w+)((\[|\()(\'|")?\$*\w*(\'|")?(\)|\]))*((-)?\$?(\w*)(\((\'|")?(.*?)(\'|")?\)|))){0,})( *\.?[^ \.]*? *)*?){1,})'.$rightTag.'/i',

'/'.$leftTag.'\%([\w]+)'.$rightTag.'/', //多语言

);

$replace=array(

'?php include($tpl-template("\\1"));?',

"\$this-compile_replace('\\1')",

'?php for (\\1) { ?',

'?php $__i=0; while (\\1) {$__i++; ?',

'?php if (\\1){ ?',

'?php }else{ ?',

'?php } ?',

'?php echo \\1;?',

'?php echo $this-lang["\\1"];?',

$content=preg_replace($search,$replace,$content);

file_put_contents($compiledFile,$content,LOCK_EX);

return $compiledFile;

* 根据是否使用缓存,输出缓存文件内容

* @param string $tplFile

public function cache($tplFile,$cacheID='')

$cacheFile=$this-getCacheFileName($file,$cacheID);

if ($this-cached($file,$cacheID)) {

readfile($cacheFile);

exit;

} elseif ($this-caching) {

ob_start(array($this,'_saveCache'));

$this-cacheFile=$cacheFile;

* 返回编译后的模板文件完整路径

public function template($file='')

return $this-compile($file);

* 回调函数,供cache()函数使用

* @param string $output

public function _saveCache($output)

$cacheDir=$this-cacheDir.$this-cacheDirLevel;

file_put_contents($this-cacheFile,$output,LOCK_EX);

return $output;

}//end class

怎样用PHP来给网页做导航栏

把用PHP语言的网站改成响应式网站 需要做什么?很麻烦吗?

php不需要做什么,php只负责数据,改的话就该前端,推荐使用bootstrap

PHP和DZ哪个适合做导航网站?

你的问题没有搞清楚.

DZ是php的一个开源程序,主要用于论坛的.

你可以用CMS DEDE(织梦)、帝国CMS等做你想要的网站.

或者用专门的导航程序 如 phpLD(国外的,你Google一下)

以上就是土嘎嘎小编为大家整理的php响应式网址导航z相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章