How can I replace braces with <?php ?> in php file?

后端 未结 3 2026
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-29 16:01

I wanna replace braces with in a file with php extension. I have a class as a library and in this class I have three function like these:

         


        
3条回答
  •  野的像风
    2021-01-29 16:14

    How does this work:

    process.php:

    ', $contents);
    echo $contents;
    

    bash script:

    process.php < my_file.php
    

    Note that the above works by doing a one-off search and replace. You can easily modify the script if you want to do this on the fly.

    Note also, that modifying PHP code from within PHP code is a bad idea. Self-modifying code can lead to hard-to-find bugs, and is often associated with malicious software. If you explain what you are trying to achieve - your purpose - you might get a better response.

提交回复
热议问题