草庐IT

image-formats

全部标签

php - 拉维尔 : How to get random image from directory?

我有一个包含子目录的目录,每个子目录中都有图像。我想随机显示图像。在我的php代码下方运行良好,但在Laravel中不起作用,问题出在opendir()和readdir()上。查看Blade';?> 最佳答案 在Laravel中你需要使用Storage使用文件系统。$files=Storage::allFiles($directory);$randomFile=$files[rand(0,count($files)-1)]; 关于php-拉维尔:Howtogetrandomimagefr

php - 将属性添加到 wp_get_attachment_image

我正在尝试为wp_get_attachment_image的结果添加一个属性.我想使用jquerylazyload来处理我的帖子缩略图的加载,为此我需要添加一个data-original=属性为标签wp_get_attachment_image正在创作。我试过:$imgsrc=wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),"full");$imgsrc=$imgsrc[0];$placeholderimg=wp_get_attachment_image(2897,"full",array('data-origi

php - 匹配 HH :MM:SS time format in php? 的正则表达式

这个问题在这里已经有了答案:RegexpatternforHH:MM:SStimestring(2个答案)关闭9年前。HH:MM:SS的正则表达式是什么HH是hours,但不限于日期或时钟,它可以是从0到任何整数的任何数字MM是分钟,最大值是59,从00开始SS是Seconds最大值是59并且从00开始

PHP GD : The image cannot be displayed because it contains errors

我尝试通过PHPGD创建验证码。但不幸的是我遇到了一个问题!PHP告诉我:Theimage“http://127.0.0.1/par.php”cannotbedisplayedbecauseitcontainserrors.我的代码是这样的 最佳答案 $im=@imagecreatetruecolor(120,20)ordie('CannotInitializenewGDimagestream');你首先隐藏真正的错误并尝试显示一些东西......因为你不去寻找它而无法显示,并公开图像,无论它是否真的生成。然后你继续使用stacko

php - 如何在 HH :MM format 中的 php 中添加多个小时

我有以下数组。Array([0]=>25:50[1]=>21:00[2]=>42:40)我正在尝试在php中添加小时数,我尝试了以下代码。但它让我错误的时间计算。$time_cal=0;foreach($timeas$time_cal){$time_cal+=strtotime($time_cal);}echodate('H:i',strtotime($time_cal));这个strtotime函数背后的原因是只给出24小时的时间计算,这是正确的,但是当我尝试24小时以上的时间,比如25:55、44:44时,我的计算是错误的。有什么想法吗? 最佳答案

php - 找不到 Laravel 5 类 'Intervention\Image\ImageServiceProvider'

您好,我对干预图像有疑问。当我使用composerupdate或phpartisanvendor:publish--provider="Intervention\Image\ImageServiceProviderLaravel5"我有错误:[Symfony\Component\Debug\Exception\FatalErrorException]Class'Intervention\Image\ImageServiceProvider'notfound**你有想法吗?我从http://image.intervention.io/getting_started/installatio

php - 删除 PHP money_format() 输出中美元符号后的空格

我用money_format('%(#15.2n',$money)输出类似$500.00有没有办法去掉美元符号和500之间的空格? 最佳答案 money_format[docs]甚至可能无法在某些平台上运行。使用number_format[docs会更可靠]:echo'$'.number_format($money,2);//'$12.44'如果您希望它填充到一定数量的空格,但在数字之前紧跟美元符号,您还可以使用sprintf[docs]:echoprintf("%15s",'$'.number_format($money,2));

PHP DateTime::diff 问题与 DateTime::format

当我尝试使用正常的PHP代码(d、Y、m等)为日期和时间格式化我的日期差异时,它只输出字母,而不是值。这仅在我格式化DateTime::diff时才会发生。它适用于简单的DateTime对象。这个:$date1=newDateTime('2000-01-01');$date2=newDateTime('now');$date=$date2->diff($date1);echo$date->format('ddaysago');“d天前”的输出。我知道如果我用%a替换d,它会输出这是多少天前的信息。我想知道还有哪些字符可以输出秒、分甚至年。提前致谢! 最佳答案

php - 你能在 ""中回应 money_format() 吗?

我正在尝试回应以下内容echo"Thepriceismoney_format('$%i',$price)"但这实际上是echomoney_format('$%i',9.99)是否可以在""中回显money_format('$%i',$var_name)? 最佳答案 你需要连接运算符echo"Thepriceis".money_format('$%i',$price); 关于php-你能在""中回应money_format()吗?,我们在StackOverflow上找到一个类似的问题:

PHPAGI : Exec format error

运行phpagi时遇到问题:--Executing[123@DLPN_C:1]AGI("SIP/1000-00000001","hello_world.php")innewstack--LaunchedAGIScript/var/lib/asterisk/agi-bin/hello_world.phphello_world.php:Failedtoexecute'/var/lib/asterisk/agi-bin/hello_world.php':Execformaterror--Autofallthrough,channel'SIP/1000-00000001'statusis'UN