我现在有这个:
<input type="text" placeholder="Paste text" onPaste="alert(this.value);">
这确实有效,除了它返回一个空白警报窗口.我没有任何价值.救命?
function restyle_text($input){
$input = number_format($input);
$input_count = substr_count($input, ',');
if($input_count != '0'){
if($input_count == '1'){
return substr($input, +4).'k';
} else if($input_count == '2'){
return substr($input, +8).'mil';
} else if($input_count == '3'){
return substr($input, +12).'bil';
} else {
return;
}
} else {
return $input;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的代码,我认为它有效.显然不是..有人可以提供帮助,因为我无法解决这个问题.
我现在正在使用数十万行字符串.无论如何我可以将字符串压缩为像MD5一样,然后解压缩它?
function uploadPhoto(file) {
if (!file || !file.type.match(/image.*/)){
if(!file){
postStatus();
} else {
return;
}
}
var fd = new FormData();
fd.append("image", file);
fd.append("privacy", document.getElementById('privacy-handler').value);
var xhr = GetXmlHttpRequest();
xhr.open("POST", "url here");
slideUp('photo-upload');
slideDown('photo-manager-txt');
document.getElementById("photo-manager-txt").innerHTML='<i>Please wait a moment while we process your photo.</i>';
xhr.onload = function() {
if(xhr.responseText == '0'){
document.getElementById('photo-manager-txt').innerHTML='<br />Photo upload failed';
slideDown('photo-upload');
return;
} else {
document.getElementById('photo-txt').value='grab?v=1&file='+xhr.responseText;
document.getElementById('photo-manager-txt').innerHTML='Photo uploaded and shared.';
postStatus();
}
}
xhr.send(fd);
}
Run Code Online (Sandbox Code Playgroud)
这个功能似乎不起作用.当我调用我正在使用的函数时:
onClick="uploadPhoto(document.getElementById('ID-HERE').files[0]);"
Run Code Online (Sandbox Code Playgroud)
当我删除它0
时files[]
,它至少运行postStatus();
,但它不会上传照片.我该如何解决这个问题?
function png2jpg($originalFile, $outputFile, $quality) {
$image = imagecreatefrompng($originalFile);
imagejpeg($image, $outputFile.'.jpg', $quality);
imagedestroy($image);
}
Run Code Online (Sandbox Code Playgroud)
我正在使用它来进行图像压缩,但我一直在查找保存已保存的文件.imagedestroy()会导致此节省内存,还是会删除输出文件.
好的,所以我有点困惑.这是我现在的代码,但我发现e
修改器已被弃用.我如何将其转换为preg_replace_callback()
?我还是没弄明白.
$post = preg_replace("/\[code\]([^] )\[\/code\]/e", 'code(\'$1\')', $post);
Run Code Online (Sandbox Code Playgroud) 标题可能听起来令人困惑.但这是我的问题.我想显示数据库中显示的内容,但它可能会显示在多行中.例如:
2
2
1
1
1
1
1
1
2
Run Code Online (Sandbox Code Playgroud)
我想显示这些数据,但我不希望它重复,我只想让它显示2s和1s一次.
我现在拥有的:
$TheSQL = 'SELECT * FROM `table` WHERE `1`="'.$profileID.'" ORDER by RAND() LIMIT 10';
Run Code Online (Sandbox Code Playgroud) 目前,我的一位朋友和我一起在一个网站上工作.我们的登录系统已关闭,但正在使用会话.我,我自己,一直使用cookie登录,虽然我的朋友更喜欢会话.我一直告诉他我们应该有两个或更多的会话,我们可以与数据库进行比较,以确保它是准确的用户,而不是某人以某种方式欺骗ID.
例如:
$_SESSION['id'] = $YourId;
$_SESSION['salt'] = $SomethingElseTheDatabaseHas;
Run Code Online (Sandbox Code Playgroud)
这使得它更安全,而不仅仅是数据库可以与之比较的一个会话.
if($_POST['VIDEO']){
$video = parse_url($_POST['VIDEO']);
if($video['host'] == 'www.youtube.com' || $video['host'] == 'youtube.com'){
$query = parse_str($video['query']);
$v = $query['v'];
if(!$v){
//nothing found
} else {
$videoOutput = 'yt:'.$v;
}
}
}
Run Code Online (Sandbox Code Playgroud)
所以我大约一个月前制作了这个脚本。直到昨晚都完美地工作。我不明白为什么。直到昨晚它都可以完美运行。它实际上解析了 url,并且主机是有效的。我到了parse_str
,突然间一切都不起作用了。我做print_r
了$query
,它没有返回任何数据。如果我echo
是变量,我会得到一个1
. 这个文件甚至没有被触及,所以我不明白为什么它会突然破裂。
有什么建议?
php ×7
compression ×2
function ×2
javascript ×2
mysql ×2
string ×2
ajax ×1
copy-paste ×1
form-data ×1
gd ×1
html ×1
image ×1
input ×1
numbers ×1
preg-replace ×1
regex ×1
select ×1
session ×1
substr ×1
youtube ×1