最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

file_get_contents | escaping doesnt show the page

programmeradmin1浏览0评论

I have below code.echo $FileContents;shows the page which comes the php variable correctly, but the escape function which is <?php esc_html( $FileContents ); ?>didnt show anything.

How can I escape it correctly and show the page?

<?php global $redux_demo; ?>
<div class="row">
    <div class="col-md-12 ulockd-mrgn1210">
        <?php $FileContents = file_get_contents($redux_demo['text-location-service-details']); ?>
        <?php echo $FileContents; ?>
        <?php esc_html( $FileContents ); ?>
    </div></div>

I have below code.echo $FileContents;shows the page which comes the php variable correctly, but the escape function which is <?php esc_html( $FileContents ); ?>didnt show anything.

How can I escape it correctly and show the page?

<?php global $redux_demo; ?>
<div class="row">
    <div class="col-md-12 ulockd-mrgn1210">
        <?php $FileContents = file_get_contents($redux_demo['text-location-service-details']); ?>
        <?php echo $FileContents; ?>
        <?php esc_html( $FileContents ); ?>
    </div></div>
Share Improve this question asked Jun 16, 2020 at 2:50 Javascript Asking AccountJavascript Asking Account 51 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

Well, esc_html() doesn't echo/display the return value (escaped string), so you need to call echo manually:

echo esc_html( $FileContents );

Update

If you actually want to filter the list of allowed HTML tags in the variable's value, then you can use the WordPress' KSES functions like wp_kses_post() and wp_kses_data():

echo wp_kses_post( $FileContents );
echo wp_kses_data( $FileContents ); // allows basic HTML by default
发布评论

评论列表(0)

  1. 暂无评论