我有一个带有htaccess和htpasswd的密码保护目录.
htaccess看起来像这样
AuthUserFile /usr/local/you/safedir/.htpasswd
AuthGroupFile /dev/null
AuthName EnterPassword
AuthType Basic
require user myusername
Run Code Online (Sandbox Code Playgroud)
htpasswd看起来像这样
myusername:password887
Run Code Online (Sandbox Code Playgroud)
这个受密码保护的目录名为www.mydomainname.com/mystuff
现在,我想在我的root中的index.php中访问这个页面,将iframe(以www.mydomain.com/mustuff/index.html作为src)访问,但我不想让用户填写所有用户名和密码时间,只是让他们不进入src所在的文件夹.
是否有一个脚本可以自动填写用户名和密码而不让"用户"一直写入用户名和密码?
有没有办法推迟PHP代码?
就像在 javascript 中我们使用<script defer="defer"></script>. 有没有办法对 PHP 代码做同样的事情?
更新: 这是我使用的代码:
信息:此代码位于我的侧边栏中,会导致网站在加载时停止 2-3 秒。我试图跳过这个过程并在网站的其余部分加载时加载此代码......我也愿意接受其他编码解决方案。
<div style="padding:5px;">
<?php
function currency($from_Currency,$to_Currency,$amount) {
$amount = urlencode($amount);
$from_Currency = urlencode($from_Currency);
$to_Currency = urlencode($to_Currency);
$url = "http://www.google.com/ig/calculator?hl=en&q=$amount$from_Currency=?$to_Currency";
$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_USERAGENT , "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$rawdata = curl_exec($ch);
curl_close($ch);
$data = explode('"', $rawdata);
$data = explode('"', $data['3']);
$var = $data['0'];
return round($var,1);
} …Run Code Online (Sandbox Code Playgroud)