$string = "define('AUTH_KEY', 'put your unique phrase here');'";
$string .= 'define("SECURE_AUTH_KEY", "put your unique phrase here");';
$string .= 'define("LOGGED_IN_KEY", \'put your unique phrase here\');';
preg_match_all("/define\s*\(\s*['\"]([^'\"]+)['\"]\s*,\s*['\"]([^'\"]+)['\"]\s*\)/", $string, $matches);
var_export($matches);
と私のwp-config.php
に次のように一致させる最善の方法について助言でしたねえ、それは読みにくいですし、Perlのように見える、私はくつろぐ!
array (
0 =>
array (
0 => 'define(\'AUTH_KEY\', \'put your unique phrase here\')',
1 => 'define("SECURE_AUTH_KEY", "put your unique phrase here")',
2 => 'define("LOGGED_IN_KEY", \'put your unique phrase here\')',
),
1 =>
array (
0 => 'AUTH_KEY',
1 => 'SECURE_AUTH_KEY',
2 => 'LOGGED_IN_KEY',
),
2 =>
array (
0 => 'put your unique phrase here',
1 => 'put your unique phrase here',
2 => 'put your unique phrase here',
),
)
基本的に、これは「両方の文字列では、どちらも "があることを前提としても得られます。つまり、それらは唯一の開始と終了の文字列に使用されます。それは奇妙なことに、事故によって動作しますところでdefine("myKey', 'test')
が、PHPはそれらをコンパイルするようにしないだろうと、それらは、おそらく問題はありません。
のように、あなたは、単にwp_config.phpを含め、その後print LOGGED_IN_KEY
を言って正規表現の使用を避けることができます。