douhao6557
douhao6557
2018-10-20 00:10
浏览 35
已采纳

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

i have some question about php in css
my projet folde

What i'm trying to do : count <li> with php in css
Probleme : cannot find the right location

more information : <link rel="stylesheet" href="./css/style.php"> in my "head.php"

in my style.php

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

i tried "../index.php"; "../inc/menu.php"; "./inc/menu.php"; no one work

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doumu9799
    doumu9799 2018-10-20 00:23
    已采纳

    you can try something like this

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

相关推荐