gpt4 book ai didi

php - 如何从js代码中获取字符串值

转载 作者:行者123 更新时间:2023-11-28 09:37:49 25 4
gpt4 key购买 nike

我想获取字符串值,然后使用urldecode()

Javascript

document.write(unescape('%46%43%20%42%72%61%73%6f%76%20%76%73%2e%20%43%53%4d%53%20%49%61%73%69'));

PHP

$string = "document.write(unescape('%46%43%20%42%72%61%73%6f%76%20%76%73%2e%20%43%53%4d%53%20%49%61%73%69'));";

preg_match('/document.write(unescape(\'.*\'));/', $string,$matches);
var_dump($matches);

但是这返回array(0) { }

最佳答案

你可以试试

$string = "document.write(unescape('%46%43%20%42%72%61%73%6f%76%20%76%73%2e%20%43%53%4d%53%20%49%61%73%69'));";
preg_match('/document.write\(unescape\(\'(.*)\'\)\);/', $string,$matches);
var_dump($matches[1]);

输出

string '%46%43%20%42%72%61%73%6f%76%20%76%73%2e%20%43%53%4d%53%20%49%61%73%69' (length=69)

关于php - 如何从js代码中获取字符串值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12785870/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com