php中如何导入PHP文件

include('1.php'); //受流程控制影响
require('1.php'); //无视流程控制,一出现就加载。

❷ PHP新手,如何正确让服务器加载PHP文件(安装了MAMP)

1.应用程序——》MAMP控制面板——》Star Servers——》Preferences——》Apache——》可以看到站点根目录
类似Macintosh HD/Applications/MAMP/htdocs
把相关的php程序放那个位置访问下,比如下载个discuz
2.Apache配置文件一般在/Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
3.数据库管理和创建使用phpmyadmin
http://ip/phpmyadmin

❸ 如何在PHP文件中加载另一个网站里的PHP文件

你好,我是hicuizd,请问你是指在你、本地加载其他网站的网页吗?如果是这样的话是可以的,不过只能得到php编译之后的html脚本语言,如包含网络页面: <?$text = file_get_contents(" http://www..com "); echo $text; ?> 如果说你是指在本地包含本地另外一个网页文件叫read.php,那么这样是可以的哦,可以选用include函数进行包含,如:<?include('read.php');?>这样PHP是可以互相通信的啦。O(∩_∩)O~

❹ 怎么用php读取并显示另一个php文件的内容

示例代码1: 用file_get_contents 以get方式获取内容
代码如下:
<?php
$url='';
$html=file_get_contents($url);
//print_r($http_response_header);
ec($html);
printhr();
printarr($http_response_header);
printhr();
?>

示例代码2: 用fopen打开url, 以get方式获取内容
代码如下:
<?
$fp=fopen($url,'r');
printarr(stream_get_meta_data($fp));
printhr();
while(!($fp)){
$result.=fgets($fp,1024);
}
echo"url body:$result";
printhr();
fclose($fp);
?>

示例代码3:用file_get_contents函数,以post方式获取url
代码如下:
<?php
$data=array('foo'=>'bar');
$data=http_build_query($data);
$opts=array(
'http'=>array(
'method'=>'POST',
'header'=>"Content-type: application/x-www-form-urlencodedrn".
"Content-Length: ".strlen($data)."rn",
'content'=>$data
),
);
$context=stream_context_create($opts);
$html=file_get_contents('',false,$context);
echo$html;
?>

示例代码4:用fsockopen函数打开url,以get方式获取完整的数据,包括header和body
代码如下:
<?
functionget_url($url,$cookie=false){
$url=parse_url($url);
$query=$url[path]."?".$url[query];
ec("Query:".$query);
$fp=fsockopen($url[host],$url[port]?$url[port]:80,$errno,$errstr,30);
if(!$fp){
returnfalse;
}else{
$request="GET$queryHTTP/1.1rn";
$request.="Host:$url[host]rn";
$request.="Connection: Closern";
if($cookie)$request.="Cookie:$cookien";
$request.="rn";
fwrite($fp,$request);
while(!@feof($fp)){
$result.=@fgets($fp,1024);
}
fclose($fp);
return$result;
}
}
//获取url的html部分,去掉header
functionGetUrlHTML($url,$cookie=false){
$rowdata=get_url($url,$cookie);
if($rowdata)
{
$body=stristr($rowdata,"rnrn");
$body=substr($body,4,strlen($body));
return$body;
}
returnfalse;
}
?>

示例代码5:用fsockopen函数打开url,以POST方式获取完整的数据,包括header和body
代码如下:
<?
functionHTTP_Post($URL,$data,$cookie,$referrer=""){
// parsing the given URL
$URL_Info=parse_url($URL);
// Building referrer
if($referrer=="")// if not given use this script. as referrer
$referrer="111";
// making string from $data
foreach($dataas$key=>$value)
$values[]="$key=".urlencode($value);
$data_string=implode("&",$values);
// Find out which port is needed - if not given use standard (=80)
if(!isset($URL_Info["port"]))
$URL_Info["port"]=80;
// building POST-request:
$request.="POST ".$URL_Info["path"]." HTTP/1.1n";
$request.="Host: ".$URL_Info["host"]."n";
$request.="Referer:$referern";
$request.="Content-type: application/x-www-form-urlencodedn";
$request.="Content-length: ".strlen($data_string)."n";
$request.="Connection: closen";
$request.="Cookie:$cookien";
$request.="n";
$request.=$data_string."n";
$fp=fsockopen($URL_Info["host"],$URL_Info["port"]);
fputs($fp,$request);
while(!feof($fp)){
$result.=fgets($fp,1024);
}
fclose($fp);
return$result;
}
printhr();
?>

示例代码6:使用curl库,使用curl库之前,你可能需要查看一下php.ini,查看是否已经打开了curl扩展
代码如下:
<?
$ch = curl_init();
$timeout = 5;
curl_setopt ($ch, CURLOPT_URL, '');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
echo $file_contents;
?>

关于curl库:
curl官方网站
curl 是使用URL语法的传送文件工具,支持FTP、FTPS、HTTP HTPPS SCP SFTP TFTP TELNET DICT FILE和LDAP。curl 支持SSL证书、HTTP POST、HTTP PUT 、FTP 上传,kerberos、基于HTT格式的上传、代理、cookie、用户+口令证明、文件传送恢复、http代理通道和大量其他有用的技巧
复制代码 代码如下:
<?
functionprintarr(array$arr)
{
echo"<br> Row field count: ".count($arr)."<br>";
foreach($arras$key=>$value)
{
echo"$key=$value <br>";
}
}
?>

❺ PHP怎么调用调用另一个PHP方法文件

include_once('a.php');//引用你要的php文件;这样你就可以用里面的方法了

❻ thinkphp怎样在html加载php文件

thinkphp有个<php></php>标签,里面可以写php代码,在标签里面直接clude文件,我想是可以的。

❼ PHP是什么文件如何打开PHP文件呢

这个同CGI,ASP一样,是一种用于网络或网站的程序文件。对于浏览者,这种文件显示结果跟HTML文件是一样的。
最简单的就是使用记事本就可以打开PHP文件,如果是作开发,安装专业的编辑器(如editplus等等)就更方便

❽ PHP 如何引入另一个服务器上的PHP文件

通常的处理方式是通过 fopensock() 函数来进行http请求远程服务器的结果。
所以我猜测,内您的需求容应该是想使用其他机器上的代码文件,以达到您代码共用的目的。针对此问题,我们只需要让另外一台机器上的php可访问,并可以返回结果即可。还有一种就是直接认为是跨域文件调用,我们可以借助juery.getScript() 来进行跨域加载。可以多尝试一下。

❾ 请问php中如何调用php文件中的内容

tpl使用{php}混编php代码。
例如
{php}echo "2333";{/php}
同理。
{php}include '.a.php';{/php}
可能是题主想要的结果。
不过需要确认好相对路专径属的初始路径,不一定为TPL所在目录,也有可能为调用tpl的源php所在的目录。

PS:WHMCS中使用php标签需要在安全中,允许模板嵌入php标签。

❿ php如何通过url调用php文件中的方法

题主所描述的这种形式,是MVC设计模式的典型应用。

通过使用PSR4来实现自动加载,内可以通过处理容路由来实现

//处理路由的方法
staticpublicfunctionroute()
{
//获取的模块
$_GET['m']=isset($_GET['m'])?$_GET['m']:'Index';

//获取行为动作action又叫方法
$_GET['a']=isset($_GET['a'])?$_GET['a']:'index';

$controller='Controller\'.$_GET['m'].'Controller';
//echo$controller;
$c=new$controller();

//$c->$_GET['a']();
call_user_func(array($c,$_GET['a']));
}

最终可实现以下形式: