如何检查数组变量
$a = array('a'=>1, 'c'=>null);
Run Code Online (Sandbox Code Playgroud)
已设置且为null.
function check($array, $key)
{
if (isset($array[$key])) {
if (is_null($array[$key])) {
echo $key . ' is null';
}
echo $key . ' is set';
}
}
check($a, 'a');
check($a, 'b');
check($a, 'c');
Run Code Online (Sandbox Code Playgroud)
是否有可能在PHP中具有检查$ a ['c']是否为空的函数以及如果$ a ['b']存在而没有"PHP Notice:..."错误?
如何更改Zend_Log的日期格式?
现在每个新日志条目前都有添加时间戳的日期:
"2013-01-28T16:47:54 + 01:00 ......某些日志消息..."
但我想格式化这个日期:
"Ymd H:我:s ...一些日志消息..."
我的代码看起来像这样:
class Game_Logger {
public function __construct($val, $txt = null) {
$writer = new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../log/log.log');
$logger = new Zend_Log($writer);
if (is_array($val)) {
$output = Zend_Debug::dump($val, null, false);
} else {
$output = $val;
}
if($txt){
$output = $txt.' '.$output;
}
$logger->info($output);
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个HTML字符串,我想将其作为文件附加到邮件中。我可以将此字符串保存到文件中并附加它,但是我想在不将其保存到文件中的情况下进行操作。我认为应该有可能,但我不知道该怎么做。这是我的代码:
String html = "<html><body><b><bold</b><u>underline</u></body></html>";
Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:"));
intent.setType("text/html");
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(html));
// this is where I want to create attachment
intent.putExtra(Intent.EXTRA_STREAM, Html.fromHtml(html));
startActivity(Intent.createChooser(intent, "Send Email"));
Run Code Online (Sandbox Code Playgroud)
如何将字符串作为文件附加到邮件中?
X 和 y 是对象的坐标。Z 始终为 0。如何使用 Three.js 将此对象移动(使用可见的移动动画,而不是在不同位置弹出)到新位置?
编辑:对象(网格)的代码示例
var mesh = new THREE.Mesh(new THREE.PlaneBufferGeometry(2, 2), new THREE.MeshBasicMaterial({img: THREE.ImageUtils.loadTexture('img.png')}))
scene.add(mesh)
Run Code Online (Sandbox Code Playgroud)
编辑2:我可以使用mesh.position.x = newx和mesh.position.y = newy使我的网格跳转到新位置,但我希望它看起来像JQuery animate()一样平滑。
我有这个代码:
echo PHP_INT_MAX . '<br/>';
echo 174400 * 249600 . '<br/>';
$img = imagecreatetruecolor(174400, 249600);
Run Code Online (Sandbox Code Playgroud)
它给了我这个输出:
9223372036854775807
43530240000
Warning: imagecreatetruecolor(): gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully in /home/bartek/Documents/WWW/WOF/application/controllers/EditorController.php on line 53
Run Code Online (Sandbox Code Playgroud)
第一个问题是为什么 imagecreatetruecolor 会优雅地失败?第二个问题是我能做些什么?如何在 PHP 中创建大图像?