我有这个字符串:
无功/日志/ file.log
我最终希望得到一个如下所示的数组:
Array => [
'1' => 'var',
'2' => 'var/log',
'3' => 'var/log/file.log'
]
Run Code Online (Sandbox Code Playgroud)
我目前有这个:
<?php
$string = 'var/log/file.log';
$array = explode('/', $string);
$output = [
1 => $array[0],
2 => $array[0]. '/' .$array[1],
3 => $array[0]. '/' .$array[1]. '/' .$array[2]
];
echo '<pre>'. print_r($output, 1) .'</pre>';
Run Code Online (Sandbox Code Playgroud)
这感觉非常违反直觉,我不确定PHP中是否已经内置了可以解决这个问题的东西.
如何使用追加前一个值来构建数组?
我将项目设置为prod
模式,.env
除了自定义错误页面之外的所有内容似乎都有效.
我有这个作为我的404枝条模板:
{# templates/bundles/TwigBundle/Exception/error404.html.twig #}
{% include 'builder/layout/header.html.twig' with {'title': '404'} %}
<img src="{{ assets('img/not-found.jpeg') }}" class="img-responsive"
id="error-not-found-img" />
<div class="http-error-msg-container">
<h1>404! Page Not Found</h1>
<p>Don't despair, go back to <a href="{{ path('dashboard') }}">Home</a> and try again.</p>
</div>
{% include 'builder/layout/footer.html.twig' %}
Run Code Online (Sandbox Code Playgroud)
并转到一个不存在的页面(比如说/dashboard/giorgoirdjfisejf
)返回一个空白页面.所以我把它添加到我的index.php
文件中:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);
Run Code Online (Sandbox Code Playgroud)
显示错误,我得到了这个:
致命错误:第107行/var/www/solomon/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php中允许的内存大小为134217728字节(试图分配20480字节)
致命错误:在第1行的/var/www/solomon/vendor/symfony/debug/Exception/OutOfMemoryException.php中,允许的内存大小为134217728字节(试图分配32768字节)
我不太清楚为什么这会导致错误并且无法调试.var/log/prod.log
没有显示任何内容,如何解决或更好,我该如何调试?
谢谢
我的prod/monolog.yaml文件
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
excluded_404s:
# regex: exclude all 404 …
Run Code Online (Sandbox Code Playgroud) 所以我一直在关注这个数据库和Doctrine教程:https://symfony.com/doc/current/doctrine.html
唯一的区别是我添加了一个created_ts
字段(在其他一些字段中,但它们工作正常,所以不需要进入它们).
我使用该make:entity
命令生成我的类,并设置我created_ts
生成的方法如下:
public function setCreatedTs(\DateTimeInterface $created_ts): self
{
$this->created_ts = $created_ts;
return $this;
}
Run Code Online (Sandbox Code Playgroud)
所以在我的/index
页面中,我使用以下命令保存新实体:
$category->setCreatedTs(\DateTimeInterface::class, $date);
Run Code Online (Sandbox Code Playgroud)
我有一种有趣的感觉,这会出错,我是对的:
Type error: Argument 1 passed to App\Entity\Category::setCreatedTs() must implement interface DateTimeInterface, string given
Run Code Online (Sandbox Code Playgroud)
但我不知道如何实现DateTimeInterface
内部功能..我尝试谷歌搜索但它显示了很多Symfony2
帖子,一些我试图无济于事.
如何datetime
在->set
方法中设置实体中的值?
(如果已经有答案,请链接.#symfonyScrub)
# tried doing this:
$dateImmutable = \DateTime::createFromFormat('Y-m-d H:i:s', strtotime('now')); # also tried using \DateTimeImmutable
$category->setCategoryName('PHP');
$category->setCategoryBio('This is a category for PHP');
$category->setApproved(1);
$category->setGuruId(1);
$category->setCreatedTs($dateImmutable); # …
Run Code Online (Sandbox Code Playgroud) 好的,所以我今天早上已经做了:
我跑了这个命令:
sudo apt install php7.3-curl && \
sudo apt install php7.3-enchant && \
sudo apt install php7.3-gmp && \
sudo apt install php7.3-intl && \
sudo apt install php7.3-mbstring && \
sudo apt install php7.3-opcache && \
sudo apt install php7.3-pspell && \
sudo apt install php7.3-snmp && \
sudo apt install php7.3-sybase && \
sudo apt install php7.3-xmlrpc && \
sudo apt install php7.3-bcmath && \
sudo apt install php7.3-cli && \
sudo apt install php7.3-dba && …
Run Code Online (Sandbox Code Playgroud) 我有SQL,在我的头脑中,将在1秒内运行:
SELECT mem.`epid`,
mem.`model_id`,
em.`UKM_Make`,
em.`UKM_Model`,
em.`UKM_CCM`,
em.`UKM_Submodel`,
em.`Year`,
em.`UKM_StreetName`,
f.`fit_part_number`
FROM `table_one` AS mem
INNER JOIN `table_two` em ON mem.`epid` = em.`ePID`
INNER JOIN `table_three` f ON `mem`.`model_id` = f.`fit_model_id`
LIMIT 1;
Run Code Online (Sandbox Code Playgroud)
当我在终端中运行时,这个SQL在16秒内执行.但是,如果我删除该行:
INNER JOIN `table_three` f ON `mem`.`model_id` = f.`fit_model_id`
Run Code Online (Sandbox Code Playgroud)
然后它在0.03秒内执行.不幸的是,我不确定如何调试MYSQL性能问题.这导致我的PHP脚本在尝试执行查询时耗尽内存.
这是我的表结构:
table_one
+----------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+---------+------+-----+---------+-------+
| epid | int(11) | YES | | NULL | |
| model_id | int(11) | YES | | NULL …
Run Code Online (Sandbox Code Playgroud) 介绍
我一直在试图弄清楚如何创建一个由用户名值控制的重置密码表单。
错误
Path Message Invalid value Violation
data.email This value should not be blank. null
ConstraintViolation {#945 ?
-message: "This value should not be blank."
-messageTemplate: "This value should not be blank."
-parameters: [?]
-plural: null
-root: Form {#620 ?}
-propertyPath: "data.email"
-invalidValue: null
-constraint: NotBlank {#477 …}
-code: "c1051bb4-d103-4f74-8988-acbcafc7fdc3"
-cause: null
}
Run Code Online (Sandbox Code Playgroud)
什么预期
使用新密码更新我的用户对象。
我的代码
忘记控制器.php
我知道这可能不是获取密码的正确方法,但是搜索 Symfony 4 忘记密码表单会显示与我的版本无关的 symfony2.4 帖子
<?php
namespace App\Controller\User;
use App\Entity\User;
use App\Form\User\ChangePasswordType;
use App\Repository\UserRepository;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
class …
Run Code Online (Sandbox Code Playgroud) console.log(false === 0) // false
console.log(false === !1) // true, why does it equate to true using !?
Run Code Online (Sandbox Code Playgroud)
反之亦然
console.log(true === 1 ) // false
console.log(true === !0) // true
Run Code Online (Sandbox Code Playgroud)
我理解平等和身份之间的区别,但无法理解JS的这种行为.请解释 ?
我尝试以这种方式使用range():
echo '<pre>'. print_r(range('A1', 'A4'), 1) .'</pre>';
Run Code Online (Sandbox Code Playgroud)
创建此数组:
A1
A2
A3
A4
Run Code Online (Sandbox Code Playgroud)
但实际上它返回了:
Array
(
[0] => A
)
Run Code Online (Sandbox Code Playgroud)
阅读文档会确认这种用途不是预期用途。
我可以使用以下代码获得所需的结果:
$myRange = ['A1', 'A2', 'A3', 'A4'];
Run Code Online (Sandbox Code Playgroud)
但是使用4时感觉效率很低,虽然还不错,但是当任务变成三位数时,任务就变成了Herculian。PHP内置了一些可以处理字母数字范围生成的东西吗?
谢谢,
谢谢
laravel 给出错误打开所需的 thrn (file path)(include_path='C:\xampp\php\PEAR')in (file path)
//my index file code id shown below
//require __DIR__.'public/vendor/autoload.php';
require_once $_SERVER['DOCUMENT_ROOT'].'public/vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
| …
Run Code Online (Sandbox Code Playgroud) 我为Wordpress网站创建了一个粘贴页脚。我给了该部分ID,#formfooter
并使用了以下CSS:
#formfooter{
position:fixed;
bottom: 0px;
width: 100%;
z-index: 999;
}
Run Code Online (Sandbox Code Playgroud)
现在,我想相应地扩大网站的高度。当用户向下滚动到底部时,粘性页脚将覆盖底部的内容。我如何使其向下滚动一点?