douhao6557 2018-10-19 16: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 2018-10-19 16:23
    关注

    you can try something like this

    $menu = file_get_contents('../index.php');
    $liCount = substr_count($menu,'<li>');
    echo $liCount;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部