您想要使用的函数是sanitize_text_field()
其中包括剥离所有HTML标记,删除换行符、制表符和额外的空白。
// This worked fine for me - I got /directory/subdirectory/
$value = sanitize_text_field( \'/directory/subdirectory/\' );
// And so does this one - I got /thisfile.min.js
$value = sanitize_text_field( \'/thisfile.min.js\' );
// Even with an actual form input (e.g. <input name="my_field">),
// the function worked just fine (using the same data as above).
$value = sanitize_text_field( $_POST[\'my_field\'] );
那么你已经尝试过这个功能了吗?你确定它剥夺了
/
? 其他类似的功能如何
listed here?