gpt4 book ai didi

php - 在 css 中使用 php,substr_count() 搜索文件位置

转载 作者:行者123 更新时间:2023-11-28 00:56:53 24 4
gpt4 key购买 nike

我对 css 中的 php 有一些疑问
my projet folde

我正在尝试做的事情:计数 <li>在 CSS 中使用 PHP
问题:找不到正确的位置

更多信息:<link rel="stylesheet" href="./css/style.php">在我的“head.php”中

在我的 style.php 中

<?php
header("Content-type: text/css; charset: UTF-8");
$menu="../index.php";
$li=substr_count($menu,"<li>");
echo $menu;
?>

我试过“../index.php”; “../inc/menu.php”; “./inc/menu.php”;没有人工作

最佳答案

你可以试试这个

$menu = file_get_contents('../index.php');
$liCount = substr_count($menu,'<li>');
echo $liCount;

关于php - 在 css 中使用 php,substr_count() 搜索文件位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52901312/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com