我正在尝试将一个单词替换为一些 php 代码
$filecontent = [regex]::Replace($filecontent, $myword, $phpcode)
但是 $phpcode 有一些使用特殊变量 $_ 的 php 代码
<?php $cur_author = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author)); ?>
问题是,当代码在 $filecontent 中被替换时,它会将 php 代码( $_GET )中的 $_ 变量替换为管道中的变量。
像 $author_name 这样的其他变量不会发生这种情况。
我该如何解决这个问题?