WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] how to get content from a .txt file in functions.php (4 posts)

  1. Wpkab
    Member
    Posted 5 months ago #

    Hi
    I spent hours trying to make a simple thing which work in php environement but doesn't with wordpress :

    How to open a simple .txt file and use its content within a function in the functions.php of the theme?

    My basic script is :

    <?php
    $fp = fopen ("fichier.txt", "r");
    $data = fgets ($fp);
    fclose ($fp);
    ?>

    Can I use this script in a function?
    Thanks for any help

  2. Wpkab
    Member
    Posted 5 months ago #

    and now it works... without changing anything

  3. Rod Whiteley
    Member
    Posted 5 months ago #

    I would have used file_get_contents(), but if it works it works.

  4. Wpkab
    Member
    Posted 5 months ago #

    thanks Rod

Reply

You must log in to post.

About this Topic