rename('/images/old_name.jpg', '/images/new_name.jpg');
Run Code Online (Sandbox Code Playgroud)
此代码提供的文件未找到.
调用文件的脚本放在/source/文件夹中.
文件可以从中打开 http://site.com/images/old_name.jpg
如何从root获取这些文件?
var one = 1415;
var two = 2343;
var three = 11;
Run Code Online (Sandbox Code Playgroud)
如何从这些变量中获得最大数量?
我的网站上有出生日期格式12.01.1980.
$person_date (string) = Day.Month.Year
Run Code Online (Sandbox Code Playgroud)
想要添加一个人的故乡.像" 目前30年 "(2010年 - 1980年= 30年).
但是几年来的功能不能给出完美的结果:
如果出生日期是12.12.1980当前日期是01.01.2010该人没有30岁.这是29年零一个月.
必须对出生年份,月份和出生日期进行计算,并与当前日期进行比较:
0)解析日期.
Birth date (Day.Month.Year):
Day = $birth_day;
Month = $birth_month;
Year = $birth_year;
Current date (Day.Month.Year):
Day = $current_day;
Month = $current_month;
Year = $current_year;
Run Code Online (Sandbox Code Playgroud)
1)年份比较,2010年 - 1980年=写"30"(让它$total_year变化)
2)比较月份,如果(出生日期月份大于当前月份(如出生时12和01当前)){从$total_year变量(30 - 1 = 29)} 减去一年.如果发生减号,则在此时完成计算.否则进入下一步(3步).
3) else if (birth month < current month) { $total_year = $total_year (30); }
4) else if (birth …
图像和脚本托管在同一个帐户(一个站点)上,但我们只知道图像的URL.
$image = "http://example.com/images/full-1091.jpg"
Run Code Online (Sandbox Code Playgroud)
我们怎样才能得到这个文件的大小?
伪代码:
{ do something with $image and get $image_size }
echo $image_size;
Run Code Online (Sandbox Code Playgroud)
我希望$image_size格式化为人类可读的文件大小,如"156,8 Kbytes"或"20,1 Mbytes".
我正在尝试使用date_diff():
$datetime1 = date_create('19.03.2010');
$datetime2 = date_create('22.04.2010');
$interval = date_diff($datetime1, $datetime2);
echo $interval->format('%R%d days');
Run Code Online (Sandbox Code Playgroud)
它不适合我,给出一个错误:
Call to undefined function date_diff()
Run Code Online (Sandbox Code Playgroud)
我怎样才能让它发挥作用?
使用PHP 5.2.
谢谢.
在我的网站上,我有一个名为$user_data包含表单输入的变量.然后我在用户页面上显示此变量(通过echo).
使用此变量避免任何安全风险的最佳方法是什么?我用strip_tags(),但还不够.
此变量也会保存到MySQL数据库中.
$(".block li").hover(
function(){
$(this).animate({backgroundColor: "#000"});
},
function(){
$(this).animate({backgroundColor: "#fff"});
}
);
Run Code Online (Sandbox Code Playgroud)
需要改为#fff无颜色.动画应该从发生#000到transparent.
有解决方案吗
我们有一个像http://site.s3.amazonaws.com/images/some image @name.jpg里面的网址$string
我正在尝试做什么(是的,网址周围有一个空格):
$string = urlencode(trim($string));
$string_data = file_get_contents($string);
Run Code Online (Sandbox Code Playgroud)
我得到了什么(@也被替换):
file_get_contents(http%3A%2F%2Fsite.s3.amazonaws.com%2Fimages%2Fsome+image+@name.jpg)[function.file-get-contents]: failed to open stream: No such file or directory
如果您复制/粘贴http://site.s3.amazonaws.com/images/some image @name.jpg到浏览器地址栏中,图像将会打开.
有什么不好以及如何解决这个问题?
我的朋友在我的脚本中发现了一个问题,它提供了对根文件的访问.
这个url给出了passwd文件:
http://site.com/attachment.php?file=../../../../../../etc/passwd
Run Code Online (Sandbox Code Playgroud)
如何逃脱这个安全漏洞?
$variable = 'put returns between paragraphs';
Run Code Online (Sandbox Code Playgroud)
每次变化时此变量的值.
如何在最后一个单词之前添加一些文字?
就像,如果我们想要添加'and',结果应该是(对于这个例子):
$variable = 'put returns between and paragraphs';
Run Code Online (Sandbox Code Playgroud)