Can't make PHP function work inside HTML inside PHP

后端 未结 2 1539
南笙
南笙 2020-12-12 05:29

I wrote this code, it gets an image from a link that varies according to where you are:



        
相关标签:
2条回答
  • 2020-12-12 06:01

    You are already inside the php tag. So there is no need for <?php and ?>.

    Try:

    echo "<img src='http://chusmix.com/Imagenes/grupos/".substr($search,1).".jpg'>";
    
    0 讨论(0)
  • 2020-12-12 06:07

    Replace line

    echo "<img src='http://chusmix.com/Imagenes/grupos/<?php echo substr(get_search_query(), 1); ?>.jpg'>";
    

    with

    echo "<img src='http://chusmix.com/Imagenes/grupos/" . substr(get_search_query(), 1) . ".jpg'>";
    
    0 讨论(0)
提交回复
热议问题