我正在为我的子页面产品使用TAB导航 - > ?p=products(参见下面的代码,网站是用HTML和PHP实现的)
问题:
例如,用户在第二个TAB中单击链接详细信息.然后他使用后退按钮.现在他回到产品网站,但不是在第二个标签中,而是在第一个标签中.
href="#section-2"如果用户返回产品页面,我想记住上次使用的标签(此处:).
有谁知道我怎么能意识到这一点?
<div id="tabs" class="tabs">
<nav>
<ul>
<li><a href="#section-1" class="icon-cross"><span>Product 1</span></a></li>
<li><a href="#section-2" class="icon-cross"><span>Product 2</span></a></li>
<li><a href="#section-3" class="icon-cross"><span>Product 3</span></a></li>
<li><a href="#section-4" class="icon-cross"><span>Product 4</span></a></li>
</ul>
</nav>
<div class="content">
<section id="section-1">
<div class="tab-heading">
<hr>
<h2 class="intro-text text-center"><strong>Product 1</strong></h2>
<hr>
</div>
...
</section>
<section id="section-2">
<div class="tab-heading">
<hr>
<h2 class="intro-text text-center"><strong>Product 2</strong></h2>
<hr>
</div>
<a href="?p=details">Details</a>
</section>
</div>
</div>
Run Code Online (Sandbox Code Playgroud) 我将 Visual Studio Code 1.16.1 与 Felix Becker 的PHP Debug 扩展一起使用。我连接到 XDebug 就好了,可以在调试窗格中设置断点和查看变量,没有任何问题。
但是,调试控制台似乎没什么用,我只能运行超级基本的 PHP 命令,而且我似乎无法评估正常的 PHP 命令或与我的应用程序很好地交互。
error evaluating code尝试在调试控制台中键入任何 PHP 语句或表达式时,我始终如一。似乎我所能做的就是声明变量、数组和对象。
我不能声明的类,函数,使用控制结构(if,foreach等)。
作品:
$x = 4
//4
$x
//4
$x = new stdClass();
//stdClass
$x = [];
//array(0)
($x) ? yes : no
// yes
(!$x) ? yes : no
// no
preg_replace('/dog/', 'cat', 'The quick brown fox jumps over the lazy dog.')
// "The quick brown fox jumps over the …Run Code Online (Sandbox Code Playgroud) 我想我要疯了。我已经到处搜索,似乎无法在 Stack、GitHub 和其他遥远的互联网上找到可行的解决方案。
在这个特定的项目中,跑步docker-compose build需要FOREVER。以前不是这样的,在其他使用 Docker 的项目上,这根本不是问题。并且永远......我说的是大约 10-15 分钟的构建时间,而过去它只需要大约 2 分钟。我有两个单独的同事 DL同一个 repo(一个在 Ubuntu 18 上,另一个在 macOS 14.x 上)。当他们运行build命令时,整个过程大约需要 2 分钟。这两个人以前从未建立过这个项目,所以他们是从零开始的。
我已经卸载/重新安装了 Docker,运行了一个完整的docker system prune -a,通过 wifi 连接,通过以太网连接,尝试了不同的 wifi 网络,调整了我的撰写文件,调整了我的 docker 文件——什么都没有。
我的机器是 2018 款 MacBook Pro,配备四核 2.7GHz i7,运行 macOS 10.14.6,安装有 16GB RAM 和 Docker Desktop 2.1.0.5。
我已经允许 Docker Desktop 拥有高达 12gb 或 RAM。在构建过程中,我的机器 CPU 使用率在运行该com.docker.hyperkit过程时平均从 110% 飙升至 270% 。
需要明确的是,在任何事情真正开始之前,它都挂在“Building php”(或“Building web”)状态消息上。之后,实际的构建过程会顺利而快速地运行。
这是我的 docker-compose.yaml文件:
version: …Run Code Online (Sandbox Code Playgroud) 我尝试在 VS Code for PHP 上使用 Live-Server 扩展,但它只打开了“服务”项目文件夹的“根”,并将其显示index.php为可下载的文件链接。
然后我阅读了 Live-Server Web Extension 并安装了它,但它仍然无法正常工作。
(是的,我确实在 VS Code 的 Live-Server 配置设置中启用了 Web 扩展)。
我还尝试使用 PHP Server 扩展,它在为项目提供服务方面做得很好,而不是在 XAMPP 中使用 Apache,但我还没有找到保存时重新加载的方法。
有没有办法在 PHP 服务器上自动重新加载 PHP?
除了安装在 VS Code 中的 Live-Server 并在 Live-Server 配置设置中启用 Web 扩展之外,Live-Server Web 扩展是否需要其他东西?
我已经看到它对 gif/视频中的某些人有效,但我没有设法解决。
我想在 PHP 7.4 中检查属性是否真正初始化。将属性设置为 null 意味着它是用 null 初始化的。
我无法使用,isset因为即使它设置为 null,它也会返回 false。
我无法使用,property_exists因为即使未初始化它也会返回 true。
我知道的唯一方法是 with ReflectionProperty::isInitialized,但这感觉有点奇怪,我需要使用这个弯路。
class DTO {
public ?string $something;
}
$object = new DTO();
$object->something = null;
isset($object->something); //returns false
is_initialized($object->something); //should return true;
Run Code Online (Sandbox Code Playgroud)
我可以使用 ReflectionProperty 编写这个函数,但也许我遗漏了一些东西?
在测试我的php脚本是否与php-8兼容时,我遇到了以下代码:
function getDir($a, $o = 2) {
$d = Floor($a / $o);
return ($d % 2 === 0);
}
Run Code Online (Sandbox Code Playgroud)
在php-8之前,这工作正常,但是,在php-8 上它抛出:
致命错误:无法重新声明 getDir()
经过一段时间的搜索,我发现php-8引入了一个新的别名dir():
/** @param resource $context */
function getdir(string $directory, $context = null): Directory|false {}
Run Code Online (Sandbox Code Playgroud)
dir() 没有提到别名我在 Windows 10 中遇到以下问题(在 Ubuntu 中工作正常):
我正在 Laravel 8 中使用 Sail 当我APP_PORT在.env...上创建变量时
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_PORT=3000
Run Code Online (Sandbox Code Playgroud)
...并启动网络,sail up我收到此错误:
services.laravel.test.ports contains an invalid type, it should be a number, or an object
Run Code Online (Sandbox Code Playgroud)
这就是docker-compose.yml看起来的样子
version: '3'
services:
laravel.test:
build:
context: ./docker/8.0
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
image: sail-8.0/app
ports:
- '${APP_PORT:-80}:80'
...
Run Code Online (Sandbox Code Playgroud)
我知道我可以直接输入ports: - '3000:80',但由于我在团队中工作并且该php artisan sail:install命令将覆盖该docker-compose.yml文件,因此我不想更改该docker-compose.yml文件。
提前致谢。
我对如何解决这个问题有点困惑。我对运行 Apache2 的服务器进行了发行版升级。
自从升级之后就没有用了。我运行了配置测试,下面是错误。我在之前版本的 Ubuntu (21.10) 上的配置没有任何问题
$ apache2ctl configtest
apache2: Syntax error on line 146 of /etc/apache2/apache2.conf: Syntax error on line 3 of /etc/apache2/mods-enabled/php8.0.load: Cannot load /usr/lib/apache2/modules/libphp8.0.so into server: /usr/lib/apache2/modules/libphp8.0.so: cannot open shared object file: No such file or directory
Action 'configtest' failed.
The Apache error log may have more information.
Run Code Online (Sandbox Code Playgroud)
有什么想法从哪里开始吗?我对 Apache 还相当缺乏经验。
我们在提供商 wpengine 上安装了 WordPress。当我们尝试更新某些插件时,我们在主题中遇到致命的 PHP 错误。提供商支持不知道如何帮助我们。这是错误的调用堆栈:
“PHP 致命错误:未捕获错误:调用 /nas/content/live/sillaindustrie/wp-includes/class-wp-textdomain-registry.php:103\n堆栈跟踪:\n#0 /nas 中未定义的函数 Trailingslashit() /content/live/sillaindustrie/wp-includes/l10n.php(784): WP_Textdomain_Registry->set('default', 'it_IT', '/nas/content/li...')\n#1 /nas/ content/live/sillaindustrie/wp-includes/load.php(1401): load_textdomain('default', '/nas/content/li...', 'it_IT')\n#2 /nas/content/live/ sillaindustrie/wp-includes/load.php(278): wp_load_translations_early()\n#3 /nas/content/live/sillaindustrie/wp-settings.php(74): wp_maintenance()\n#4 /nas/content/ live/sillaindustrie/wp-config.php(67): require_once('/nas/content/li...')\n#5 /nas/content/live/sillaindustrie/wp-load.php(50): require_once ('/nas/content/li...')\n#6 /nas/content/live/sillaindustrie/wp-blog-header.php(13): require_once('/nas/content/li...' )\n#7 /nas/content/live/sillaindustrie/index.php(17): require('/nas/content/li...')\n#8 {main}\n 放入 /nas/content /live/sillaindustrie/wp-includes/class-wp-textdomain-registry.php 第 103 行,参考:https://silla.industries/wp-admin/update-core.php?action=do-plugin-upgrade"
它似乎与 WPML 插件或类似相关,有什么建议吗?谢谢G。
我尝试更新 WordPress 插件,但我无法理解错误的来源。也许是插件不兼容,但我不知道如何发现它。
php ×10
docker ×2
laravel ×2
alias ×1
apache ×1
debugging ×1
dockerfile ×1
html ×1
laravel-8 ×1
laravel-sail ×1
migration ×1
php-7.4 ×1
php-8 ×1
plugins ×1
properties ×1
ubuntu-22.04 ×1
webserver ×1
wordpress ×1
xampp ×1
xdebug ×1