Fatal error: Call to undefined function curl_init
resource curl_init ([ string $url = null ] )
修改配置:
1.修改php教程.ini,将;extension=php_curl.dll前面的分号去掉
2.拷贝libeay32.dll、ssleay32.dll(c:apps教程ervphp5)两个文件到system32目录
3.重启apache(services.msc)即可
<?php
echo "curl - function test <br>" ;
if ($load == 1){
function webcheck ($url) {
$ch = curl_init ($url) ;
curl_setopt ($ch, curlopt_returntransfer, 1) ;
$res = curl_exec ($ch) ;
curl_close ($ch) ;
return ($res) ;
}
echo "url = $url <br>" ;$erg = webcheck("my_page.php/test_1.php") ;
$zahl = strlen ($erg) ;
echo "length = $zahl " ;
?>
如果你在使用过程出现fatal error: call to undefined function curl_init(),试着做如下操作
你看看php的phpinfo()中有没有curl扩展支持!
把php_curl.dll拷到c:windows和c:windowssystem32里面 重启apache
之后再试试看
不是php_curl.dll这个文件
是把php目录中的libeay32.dll,ssleay32.dll拷到c:windowssystem32里面 重启apache
更多详细内容请查看:http://www.111cn.net/phper/31/83bccb7f05107b9ba65c22ce4dae1bf8.htm
出现这种问题是变量未定义了,我们只要把加个验证如
$a =isset($_get['aa'])?$_get['aa']:'变量未定义';
这样未定义变量也不会出现undefined variable和 undefined index
提供哦,同时我们还提供在php ini或在php中设置错误不提示的方法
解决方法:
1) error_reporting设置:
找到error_reporting = e_all
修改为error_reporting = e_all & ~e_notice
2) register_globals设置:
找到register_globals = off
修改为register_globals = on
1.1 无www域名转移到www域名
复制代码 代码如下:
rewriteengine on
rewritecond %{http_host} ^111cn.net [nc]
rewriterule ^(.*)$ http://www.111cn.net/$1 [r=301,nc]
1.2 整站301重定向
复制代码 代码如下:
options +followsymlinks
rewriteengine on
rewritecond %{http_host} ^111cn.net [nc]
rewriterule ^(.*)$ http://www.111cn.net/$1 [l,r=301]
rewritecond %{http_host} ^www.111cn.net [nc]
rewriterule ^(.*)$ http://111cn.net/$1 [l,r=301]
另外一种是在根目录下的index.php教程里这样弄
复制代码 代码如下:
header(“http/1.1 301 moved permanently”);
header(“location:http://111cn.net/”);
exit();
2、asp教程主机301重定向
在 index.asp 或 default.asp 的最顶部加入以下几行:
代码如下:
复制代码 代码如下:
<%
response.status=”301 moved permanently”
response.addheader “location”,”www.111cn.net ”
response.end
%>
3、asp.net教程主机301重定向
asp .net:
response.status = “301 moved permanently”;
response.addheader(”location”,"http://www.111cn.net");
}
我封装在一个类里:
复制代码 代码如下:
using system;
using system.collections.generic;
using system.text;
using system.web.ui;
using system.web.ui.htmlcontrols;
namespace classlib
{
public class urlclass
{
private bool flag301 = false;//是否启动 301
private bool isindex = false;//是否 返回主页 或者保留在当前页
/// <summary>
/// 构造函数
/// </summary>
/// <param name="fl">是否启动 301</param>
/// <param name="page">page</param>
/// <param name="strurl">格式www.xxx.com</param>
public urlclass(bool fl, page page, string strurl)
{
flag301 = fl;
url301(page, strurl);
}
/// <summary>
/// 返回主页
/// </summary>
/// <param name="page"></param>
/// <param name="strurl">格式www.xxx.com</param>
public void url301(page page, string strurl)
{
//301重定向
if (page.request.url.dnssafehost != strurl && flag301 == true)
{
page.response.clear();
page.response.statuscode = 301;
page.response.status = "301 movedpermanently";
page.response.addheader("location", "http://" + strurl);
page.response.end();
}
}
}
}
4 php的301重定向
复制代码 代码如下:
header('http/1.1 301 moved permanently');//发出301头部
header('location: http://www.'.$strdomain.$request_uri);//跳转到我的新域名地址
我用301.inc.php文件写了301代码,在其他文件头部都引用上 就可以了
复制代码 代码如下:
<?php
//-----------------------------------
//301 重定向
$strdomain="chinawecan.com";
$the_host = $_server['http_host']; //取得进入所输入的域名
$request_uri = isset($_server['request_uri']) ? $_server['request_uri'] : '';//判断地址后面部分
if($the_host !== 'www.'.$strdomain) //这是我要以前的域名
{
/*“!==”是不完全等于的意思,也可以用“!=”不等于,这样,就可以将以前的域名,
包括gcxirang.com、www.gcxirang.com以及新域名中我gcidc.net全部重定向到www.gcidc.net*/
header('http/1.1 301 moved permanently');//发出301头部
header('location: http://www.'.$strdomain.$request_uri);//跳转到我的新域名地址
}
//----------------------------------
?>
引用如下:
复制代码 代码如下:
中文字符判断是根据字符串编码来的,/^[chr(0xa1)-chr(0xff)]+$这就是判断是否为中文的php验证正则表达式下面来看一个验证中文实例<?php
//-----------------------------------
//301 重定向
include('include/301.inc.php');
?>5 jsp教程的301重定向
如一页面article.jsp
[code]
<%@ page language="java" contenttype="text/html; charset=utf-8" pageencoding="utf-8"%>
<%
response.setstatus(https教程ervletresponse.sc_moved_permanently);
response.setheader("location","/other.jsp");
return;
%>
$str = "一聚教程网";
if (preg_match("/^[".chr(0xa1)."-".chr(0xff)."]+$/", $str)) {
echo "这是一个纯中文字符串";
} else {
echo "这不是一个纯中文字串";
}
js
var str = "php编程";
if (/^[u4e00-u9fa5]+$/.test(str)) {
alert("该字符串全部是中文");
} else {
alert("该字符串不全部是中文");
}php
if($en_utf8)
{ $joid = preg_replace("[^0-9a-za-z_-|x4e00-x9fa5|:|/|#|.]","",$joid); } //utf-8的中文匹配
else
{ $joid = preg_replace("[^0-9a-za-z_-|".chr(0xa1)."-".chr(0xff)."|:|/|#|.]","",$joid); } //gb2312的中文匹配
php中来判断字符串是否为中文,就会沿袭这个思路:
<?php
$str = "php编程";
if (preg_match("/^[u4e00-u9fa5]+$/",$str)) {
print("该字符串全部是中文");
} else {
print("该字符串不全部是中文");
}
?>
当你需要从utf8转换一些数据,cp1251(窗- 1251)或cp1251到utf8你必须使用系统功能的iconv。常见的主机服务商不允许使用此功能。
*/
function cp1251_to_utf8($s){
$c209 = chr(209); $c208 = chr(208); $c129 = chr(129);
for($i=0; $i<strlen($s); $i++) {
$c=ord($s[$i]);
if ($c>=192 and $c<=239) $t.=$c208.chr($c-48);
elseif ($c>239) $t.=$c209.chr($c-112);
elseif ($c==184) $t.=$c209.$c209;
elseif ($c==168) $t.=$c208.$c129;
else $t.=$s[$i];
}
return $t;
}
function utf8_to_cp1251($s)
{
for ($c=0;$c<strlen($s);$c++)
{
$i=ord($s[$c]);
if ($i<=127) $out.=$s[$c];
if ($byte2){
$new_c2=($c1&3)*64+($i&63);
$new_c1=($c1>>2)&5;
$new_i=$new_c1*256+$new_c2;
if ($new_i==1025){
$out_i=168;
} else {
if ($new_i==1105){
$out_i=184;
} else {
$out_i=$new_i-848;
}
}
$out.=chr($out_i);
$byte2=false;
}
if (($i>>5)==6) {
$c1=$i;
$byte2=true;
}
}
return $out;
}
相关文章
解决springboot使用logback日志出现LOG_PATH_IS_UNDEFINED文件夹的问题
这篇文章主要介绍了解决springboot使用logback日志出现LOG_PATH_IS_UNDEFINED文件夹的问题,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-04-28Pytorch 的损失函数Loss function使用详解
今天小编就为大家分享一篇Pytorch 的损失函数Loss function使用详解,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-05-02解决jquery插件:TypeError:$.browser is undefined报错的方法
首先先说一说$.browser browser就是用来获取浏览器基本信息的。 jQuery 从 1.9 版开始,移除了 $.browser 和 $.browser.version , 取而代之的是 $.support 。 在更新的 2.0 版本中,将不再支持 IE 6/7/8。 以后,如果用户需...2015-11-24PHP “Notice: Undefined variable” 和 “Notice: Undefined index”报错
下面我们来看一篇关于PHP “Notice: Undefined variable” 和 “Notice: Undefined index”报错,希望这篇文章能够帮助到各位朋友,有兴趣的朋友可以进来看看吧。...2016-11-25PHP Notice: undefined index原因与解决办法
在php开发时可能会碰到如PHP Notice: undefined index这种错误提示,下面我来给大家介绍关于undefined index错误提示的解决办法。 如 $_GET['aa']; 就会出现PHP No...2016-11-25php提示 Warning: touch() [function.touch]: Utime failed: Permission denied in错误
在使用php程序时提示Warning: touch() [function.touch]: Utime failed: Permission denied in错误,下面一起来看看此问题的解决办法。 使用timthumb.php出现Warni...2016-11-25Warning: mssql_connect() [function.mssql-connect]:
我是这样做的,确定mssql是正常的用户名密码也可以,但下面就是不行。 <?php教程 $con=mssql_connect( "localhost", "sa ", "123456 ") or die ('error'); ?>...2016-11-25Jquery attr("checked") 返回checked或undefined 获取选中失效
假设我们现在需要这样的场景:页面上有一个checkbox,我们期望通过Jquery来获得它是否选中,或者通过Jquery来让它被选中。 在JQ1.6之前的版本,我们会这样写我们的代码: 复制代码 代码如下: <input type='checkbox' id='cb'/>...2013-10-13Java8通过Function获取字段名的方法(获取实体类的字段名称)
Java8通过Function获取字段名。不用再硬编码,效果类似于mybatis-plus的LambdaQueryWrapper,对Java8通过Function获取字段名相关知识感兴趣的朋友一起看看吧...2021-09-29php CURLOPT错误Warning: curl_setopt() [function.curl-setopt]:...
在我们使用php curl函数时提示Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir...2016-11-25- 这篇文章主要介绍了精读《Vue3.0 Function API》,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-05-20
php Fatal error: Call to undefined function imagecreatefromjpeg()
imagecreatefromjpeg函数是一个图像处理函数,但在使用中发现Fatal error: Call to undefined function imagecreatefromjpeg()错误了,下文小编整理了一些教程,大家一起来...2016-11-25php连接mysql提示Call to undefined function mysql_connect()
今天在windows中配置了php mysql环境,很高兴测试一段代码结果提示Call to undefined function mysql_connect()这证明数据库配置不成功哈。 代码如下 ...2016-11-25php提示Notice: Use of undefined constant错误
下面整理了在使用php时出现的Use of undefined constant错误的解决办法,因这关于提示Use of undefined constant错误是配置问题并不是程序错误,下面给大家整理一下解决...2016-11-25Warning: mssql_query() [function.mssql-query]:
Warning: mssql_query() [function.mssql-query]: message: 不能用 DB-Library(如 ISQL)或 ODBC 3.7 或更早版本将 ntext 数据或仅使用 Unicode 排序规则的 Unicode 数据...2016-11-25Call to undefined method DebugBar\\DebugBar::info()
我们看到英文Call to undefined method就知道是因为函数或方法没有定义了,这个对于插件就有可能是什么功能没有开启了,我们下面来看看Call to undefined method DebugBa...2016-11-25- 这篇文章主要介绍了Java8特性使用Function代替分支语句,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下...2020-09-09
iconv() [function.iconv]: Detected an illegal character in
本文章来给大家介绍iconv() [function.iconv]: Detected an illegal character in 错误的几种解决办法,有需要了解的朋友可参考。 用iconv函数将gb2312转换为utf-8...2016-11-25PHP Warning: implode() [function.implode]: Invalid
今天在做一个小的采集发布接口时发现使用implode函数老提示出错,但在网上找了一下解决不了,后来仔细看一原因是写法错误了,当然因这个问题也学了不少东西下面给各位整理...2016-11-25ASP.NET MVC @Helper辅助方法和@functons自定义函数的使用方法
本文主要介绍ASP.NET MVC中使用@Helper和@functons自定义一些代码片段,方便视图调用,从而达到减少重复代码,快速开发的目的,希望对大家有所帮助。...2021-09-22