Cant use php fopen() function in wordpress functions.php

前端 未结 2 1021
执念已碎
执念已碎 2021-01-27 11:29

I am trying to simple run fopen() in the functions.php, and have also tried it in a test.php wordpress template file.

But it does not w

2条回答
  •  孤城傲影
    2021-01-27 12:10

    You need to use the full file path instead of a relative one.

    Use the WordPress function get_template_directory() to get the path to your template directory. From there add the path to your file.

    Change:

    var_dump(csv_to_array('csv/nationality-codes.csv'));
    

    To:

    var_dump( csv_to_array( get_template_directory() . 'csv/nationality-codes.csv' ) );
    

提交回复
热议问题