本文整理汇总了PHP中save_text函数的典型用法代码示例。如果您正苦于以下问题:PHP save_text函数的具体用法?PHP save_text怎么用?PHP save_text使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了save_text函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run_test
//.........这里部分代码省略.........
}
if (is_array($IN_REDIRECT)) {
$temp_dir = $test_dir = $IN_REDIRECT['dir'];
} else {
$temp_dir = $test_dir = realpath(dirname($file));
}
if ($temp_source && $temp_target) {
$temp_dir = str_replace($temp_source, $temp_target, $temp_dir);
}
$main_file_name = basename($file, 'phpt');
$diff_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'diff';
$log_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'log';
$exp_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'exp';
$output_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'out';
$memcheck_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'mem';
$sh_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'sh';
$temp_file = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'php';
$test_file = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'php';
$temp_skipif = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'skip.php';
$test_skipif = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'skip.php';
$temp_clean = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'clean.php';
$test_clean = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'clean.php';
$tmp_post = $temp_dir . DIRECTORY_SEPARATOR . uniqid('/phpt.');
$tmp_relative_file = str_replace(__DIR__ . DIRECTORY_SEPARATOR, '', $test_file) . 't';
if ($temp_source && $temp_target) {
$temp_skipif .= 's';
$temp_file .= 's';
$temp_clean .= 's';
$copy_file = $temp_dir . DIRECTORY_SEPARATOR . basename(is_array($file) ? $file[1] : $file) . '.phps';
if (!is_dir(dirname($copy_file))) {
mkdir(dirname($copy_file), 0777, true) or error("Cannot create output directory - " . dirname($copy_file));
}
if (isset($section_text['FILE'])) {
save_text($copy_file, $section_text['FILE']);
}
$temp_filenames = array('file' => $copy_file, 'diff' => $diff_filename, 'log' => $log_filename, 'exp' => $exp_filename, 'out' => $output_filename, 'mem' => $memcheck_filename, 'sh' => $sh_filename, 'php' => $temp_file, 'skip' => $temp_skipif, 'clean' => $temp_clean);
}
if (is_array($IN_REDIRECT)) {
$tested = $IN_REDIRECT['prefix'] . ' ' . trim($section_text['TEST']);
$tested_file = $tmp_relative_file;
}
// unlink old test results
@unlink($diff_filename);
@unlink($log_filename);
@unlink($exp_filename);
@unlink($output_filename);
@unlink($memcheck_filename);
@unlink($sh_filename);
@unlink($temp_file);
@unlink($test_file);
@unlink($temp_skipif);
@unlink($test_skipif);
@unlink($tmp_post);
@unlink($temp_clean);
@unlink($test_clean);
// Reset environment from any previous test.
$env['REDIRECT_STATUS'] = '';
$env['QUERY_STRING'] = '';
$env['PATH_TRANSLATED'] = '';
$env['SCRIPT_FILENAME'] = '';
$env['REQUEST_METHOD'] = '';
$env['CONTENT_TYPE'] = '';
$env['CONTENT_LENGTH'] = '';
$env['TZ'] = '';
if (!empty($section_text['ENV'])) {
foreach (explode("\n", trim($section_text['ENV'])) as $e) {
示例2: run_test
//.........这里部分代码省略.........
}
show_test($test_idx, $shortname);
if (is_array($IN_REDIRECT)) {
$temp_dir = $test_dir = $IN_REDIRECT['dir'];
} else {
$temp_dir = $test_dir = realpath(dirname($file));
}
if ($temp_source && $temp_target) {
$temp_dir = str_replace($temp_source, $temp_target, $temp_dir);
}
$main_file_name = basename($file, 'phpt');
$diff_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'diff';
$log_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'log';
$exp_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'exp';
$output_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'out';
$memcheck_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'mem';
$temp_file = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'php';
$test_file = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'php';
$temp_skipif = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'skip.php';
$test_skipif = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'skip.php';
$temp_clean = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'clean.php';
$test_clean = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'clean.php';
$tmp_post = $temp_dir . DIRECTORY_SEPARATOR . uniqid('/phpt.');
$tmp_relative_file = str_replace(realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR, '', $test_file) . 't';
if ($temp_source && $temp_target) {
$temp_skipif .= 's';
$temp_file .= 's';
$temp_clean .= 's';
$copy_file = $temp_dir . DIRECTORY_SEPARATOR . basename(is_array($file) ? $file[1] : $file) . '.phps';
if (!is_dir(dirname($copy_file))) {
mkdir(dirname($copy_file), 0777, true) or error("Cannot create output directory - " . dirname($copy_file));
}
if (isset($section_text['FILE'])) {
save_text($copy_file, $section_text['FILE']);
}
$temp_filenames = array('file' => $copy_file, 'diff' => $diff_filename, 'log' => $log_filename, 'exp' => $exp_filename, 'out' => $output_filename, 'mem' => $memcheck_filename, 'php' => $temp_file, 'skip' => $temp_skipif, 'clean' => $temp_clean);
}
if (is_array($IN_REDIRECT)) {
$tested = $IN_REDIRECT['prefix'] . ' ' . trim($section_text['TEST']);
$tested_file = $tmp_relative_file;
$section_text['FILE'] = "# original source file: {$shortname}\n" . $section_text['FILE'];
}
// unlink old test results
@unlink($diff_filename);
@unlink($log_filename);
@unlink($exp_filename);
@unlink($output_filename);
@unlink($memcheck_filename);
@unlink($temp_file);
@unlink($test_file);
@unlink($temp_skipif);
@unlink($test_skipif);
@unlink($tmp_post);
@unlink($temp_clean);
@unlink($test_clean);
// Reset environment from any previous test.
$env['REDIRECT_STATUS'] = '';
$env['QUERY_STRING'] = '';
$env['PATH_TRANSLATED'] = '';
$env['SCRIPT_FILENAME'] = '';
$env['REQUEST_METHOD'] = '';
$env['CONTENT_TYPE'] = '';
$env['CONTENT_LENGTH'] = '';
if (!empty($section_text['ENV'])) {
foreach (explode("\n", trim($section_text['ENV'])) as $e) {
$e = explode('=', trim($e), 2);
示例3: run_test
function run_test($php, $file)
{
global $log_format, $info_params, $ini_overwrites, $toDelete;
if (DETAILED) {
echo "\n=================\nTEST {$file}\n";
}
// Load the sections of the test file.
$section_text = array('TEST' => '(unnamed test)', 'SKIPIF' => '', 'GET' => '', 'ARGS' => '', 'PCCARGS' => '', 'RTEXPECT' => '');
$fp = @fopen($file, "r") or error("Cannot open test file: {$file}");
$section = '';
while (!feof($fp)) {
$line = fgets($fp);
// Match the beginning of a section.
if (ereg('^--([A-Z]+)--', $line, $r)) {
$section = $r[1];
$section_text[$section] = '';
continue;
}
// Add to the section text.
$section_text[$section] .= $line;
}
fclose($fp);
// if we're running zend type tests, substitute EXPECT for RTEXPECT
if (getenv('ZEND_COMPAT') == 1) {
$section_text['RTEXPECT'] = $section_text['EXPECT'];
$section_text['EXPECT'] = '';
}
/* For GET/POST tests, check if cgi sapi is avaliable and if it is, use it. */
if (!empty($section_text['GET']) || !empty($section_text['POST'])) {
if (file_exists("./sapi/cgi/php")) {
$old_php = $php;
$php = realpath("./sapi/cgi/php") . ' -C ';
}
}
$shortname = str_replace($GLOBALS['cwd'] . '/', '', $file);
$tested = trim($section_text['TEST']) . " [{$shortname}]";
$tmp = realpath(dirname($file));
$tmp_skipif = $tmp . uniqid('/phpt.');
$tmp_file = ereg_replace('\\.phpt$', '.php', $file);
$tmp_post = $tmp . uniqid('/phpt.');
@unlink($tmp_skipif);
@unlink($tmp_file);
@unlink($tmp_post);
// unlink old test results
@unlink(ereg_replace('\\.phpt$', '.exp', $file));
@unlink(ereg_replace('\\.phpt$', '.out', $file));
@unlink(ereg_replace('\\.phpt$', '.rtout', $file));
@unlink(ereg_replace('\\.phpt$', '.rtexp', $file));
// Reset environment from any previous test.
putenv("REDIRECT_STATUS=");
putenv("QUERY_STRING=");
putenv("PATH_TRANSLATED=");
putenv("SCRIPT_FILENAME=");
putenv("REQUEST_METHOD=");
putenv("CONTENT_TYPE=");
putenv("CONTENT_LENGTH=");
// Check if test should be skipped.
$info = '';
$warn = false;
if (array_key_exists('SKIPIF', $section_text)) {
if (trim($section_text['SKIPIF'])) {
save_text($tmp_skipif, $section_text['SKIPIF']);
$extra = substr(PHP_OS, 0, 3) !== "WIN" ? "unset REQUEST_METHOD;" : "";
$output = `{$extra} {$php} {$info_params} -f {$tmp_skipif}`;
@unlink($tmp_skipif);
if (eregi("^skip", trim($output))) {
echo "SKIP {$tested}";
$reason = eregi("^skip[[:space:]]*(.+)\$", trim($output)) ? eregi_replace("^skip[[:space:]]*(.+)\$", "\\1", trim($output)) : FALSE;
if ($reason) {
echo " (reason: {$reason})\n";
} else {
echo "\n";
}
if (isset($old_php)) {
$php = $old_php;
}
return 'SKIPPED';
}
if (eregi("^info", trim($output))) {
$reason = ereg("^info[[:space:]]*(.+)\$", trim($output)) ? ereg_replace("^info[[:space:]]*(.+)\$", "\\1", trim($output)) : FALSE;
if ($reason) {
$info = " (info: {$reason})";
}
}
if (eregi("^warn", trim($output))) {
$reason = ereg("^warn[[:space:]]*(.+)\$", trim($output)) ? ereg_replace("^warn[[:space:]]*(.+)\$", "\\1", trim($output)) : FALSE;
if ($reason) {
$warn = true;
/* only if there is a reason */
$info = " (warn: {$reason})";
}
}
}
}
// Default ini settings
$ini_settings = array();
// additional ini overwrites
//$ini_overwrites[] = 'setting=value';
settings2array($ini_overwrites, $ini_settings);
// Any special ini settings
//.........这里部分代码省略.........
示例4: run_test
//.........这里部分代码省略.........
$exp_filename = $tmp . DIRECTORY_SEPARATOR . ereg_replace('\\.phpt$', '.exp', basename($file));
$output_filename = $tmp . DIRECTORY_SEPARATOR . ereg_replace('\\.phpt$', '.out', basename($file));
$tmp_skipif = $tmp . DIRECTORY_SEPARATOR . uniqid('/phpt.');
$tmp_file = $tmp . DIRECTORY_SEPARATOR . ereg_replace('\\.phpt$', '.php', basename($file));
$tmp_post = $tmp . DIRECTORY_SEPARATOR . uniqid('/phpt.');
if (is_array($IN_REDIRECT)) {
$tested = $IN_REDIRECT['prefix'] . ' ' . trim($section_text['TEST']) . " [{$tmp_file}]";
$section_text['FILE'] = "# original source file: {$shortname}\n" . $section_text['FILE'];
}
@unlink($tmp_skipif);
@unlink($tmp_file);
@unlink($tmp_post);
// unlink old test results
@unlink($diff_filename);
@unlink($log_filename);
@unlink($exp_filename);
@unlink($output_filename);
// Reset environment from any previous test.
putenv("REDIRECT_STATUS=");
putenv("QUERY_STRING=");
putenv("PATH_TRANSLATED=");
putenv("SCRIPT_FILENAME=");
putenv("REQUEST_METHOD=");
putenv("CONTENT_TYPE=");
putenv("CONTENT_LENGTH=");
// Check if test should be skipped.
$info = '';
$warn = false;
if (array_key_exists('SKIPIF', $section_text)) {
if (trim($section_text['SKIPIF'])) {
$skipif_params = array();
settings2array($ini_overwrites, $skipif_params);
settings2params($skipif_params);
save_text($tmp_skipif, $section_text['SKIPIF']);
$extra = substr(PHP_OS, 0, 3) !== "WIN" ? "unset REQUEST_METHOD; unset QUERY_STRING; unset PATH_TRANSLATED; unset SCRIPT_FILENAME; unset REQUEST_METHOD;" : "";
$output = system_with_timeout("{$extra} {$php} -q {$skipif_params} {$tmp_skipif}");
@unlink($tmp_skipif);
if (eregi("^skip", trim($output))) {
echo "SKIP {$tested}";
$reason = eregi("^skip[[:space:]]*(.+)\$", trim($output)) ? eregi_replace("^skip[[:space:]]*(.+)\$", "\\1", trim($output)) : FALSE;
if ($reason) {
echo " (reason: {$reason})\n";
} else {
echo "\n";
}
if (isset($old_php)) {
$php = $old_php;
}
return 'SKIPPED';
}
if (eregi("^info", trim($output))) {
$reason = ereg("^info[[:space:]]*(.+)\$", trim($output)) ? ereg_replace("^info[[:space:]]*(.+)\$", "\\1", trim($output)) : FALSE;
if ($reason) {
$info = " (info: {$reason})";
}
}
if (eregi("^warn", trim($output))) {
$reason = ereg("^warn[[:space:]]*(.+)\$", trim($output)) ? ereg_replace("^warn[[:space:]]*(.+)\$", "\\1", trim($output)) : FALSE;
if ($reason) {
$warn = true;
/* only if there is a reason */
$info = " (warn: {$reason})";
}
}
}
}
示例5: save_text
function save_text($filename, $text, $filename_copy = null)
{
if (file_put_contents($filename, (string) $text, FILE_BINARY) === false) {
error("Cannot open file '" . $filename . "' (save_text)");
}
if ($filename_copy && $filename_copy != $filename) {
save_text($filename_copy, $text);
}
}
示例6: run_test
function run_test($php, $file)
{
global $log_format, $info_params, $ini_overwrites;
if (DETAILED) {
echo "\n=================\nTEST {$file}\n";
}
// Load the sections of the test file.
$section_text = array('TEST' => '(unnamed test)', 'SKIPIF' => '', 'GET' => '', 'ARGS' => '');
$fp = @fopen($file, "r") or error("Cannot open test file: {$file}");
$section = '';
while (!feof($fp)) {
$line = fgets($fp);
// Match the beginning of a section.
if (ereg('^--([A-Z]+)--', $line, $r)) {
$section = $r[1];
$section_text[$section] = '';
continue;
}
// Add to the section text.
$section_text[$section] .= $line;
}
fclose($fp);
/* For GET/POST tests, check if cgi sapi is available and if it is, use it. */
if (!empty($section_text['GET']) || !empty($section_text['POST'])) {
if (file_exists("./sapi/cgi/php")) {
$old_php = $php;
$php = realpath("./sapi/cgi/php") . ' -C ';
}
}
$shortname = str_replace($GLOBALS['cwd'] . '/', '', $file);
$tested = trim($section_text['TEST']) . " [{$shortname}]";
$tmp = realpath(dirname($file));
$tmp_skipif = $tmp . uniqid('/phpt.');
$tmp_file = ereg_replace('\\.phpt$', '.php', $file);
$tmp_post = $tmp . uniqid('/phpt.');
@unlink($tmp_skipif);
@unlink($tmp_file);
@unlink($tmp_post);
// unlink old test results
@unlink(ereg_replace('\\.phpt$', '.diff', $file));
@unlink(ereg_replace('\\.phpt$', '.log', $file));
@unlink(ereg_replace('\\.phpt$', '.exp', $file));
@unlink(ereg_replace('\\.phpt$', '.out', $file));
// Reset environment from any previous test.
putenv("REDIRECT_STATUS=");
putenv("QUERY_STRING=");
putenv("PATH_TRANSLATED=");
putenv("SCRIPT_FILENAME=");
putenv("REQUEST_METHOD=");
putenv("CONTENT_TYPE=");
putenv("CONTENT_LENGTH=");
// Check if test should be skipped.
$info = '';
$warn = false;
if (array_key_exists('SKIPIF', $section_text)) {
if (trim($section_text['SKIPIF'])) {
save_text($tmp_skipif, $section_text['SKIPIF']);
$extra = substr(PHP_OS, 0, 3) !== "WIN" ? "unset REQUEST_METHOD;" : "";
$output = `{$extra} {$php} {$info_params} -f {$tmp_skipif}`;
@unlink($tmp_skipif);
if (eregi("^skip", trim($output))) {
echo "SKIP {$tested}";
$reason = eregi("^skip[[:space:]]*(.+)\$", trim($output)) ? eregi_replace("^skip[[:space:]]*(.+)\$", "\\1", trim($output)) : FALSE;
if ($reason) {
echo " (reason: {$reason})\n";
} else {
echo "\n";
}
if (isset($old_php)) {
$php = $old_php;
}
return 'SKIPPED';
}
if (eregi("^info", trim($output))) {
$reason = ereg("^info[[:space:]]*(.+)\$", trim($output)) ? ereg_replace("^info[[:space:]]*(.+)\$", "\\1", trim($output)) : FALSE;
if ($reason) {
$info = " (info: {$reason})";
}
}
if (eregi("^warn", trim($output))) {
$reason = ereg("^warn[[:space:]]*(.+)\$", trim($output)) ? ereg_replace("^warn[[:space:]]*(.+)\$", "\\1", trim($output)) : FALSE;
if ($reason) {
$warn = true;
/* only if there is a reason */
$info = " (warn: {$reason})";
}
}
}
}
// Default ini settings
$ini_settings = array();
// additional ini overwrites
//$ini_overwrites[] = 'setting=value';
settings2array($ini_overwrites, $ini_settings);
// Any special ini settings
// these may overwrite the test defaults...
if (array_key_exists('INI', $section_text)) {
settings2array(preg_split("/[\n\r]+/", $section_text['INI']), $ini_settings);
}
settings2params($ini_settings);
//.........这里部分代码省略.........
示例7: run_test
//.........这里部分代码省略.........
}
show_test($test_idx, $shortname);
if (is_array($IN_REDIRECT)) {
$temp_dir = $test_dir = $IN_REDIRECT['dir'];
} else {
$temp_dir = $test_dir = realpath(dirname($file));
}
if ($temp_source && $temp_target) {
$temp_dir = str_replace($temp_source, $temp_target, $temp_dir);
}
$main_file_name = basename($file, 'phpt');
$diff_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'diff';
$log_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'log';
$exp_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'exp';
$output_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'out';
$memcheck_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'mem';
$temp_file = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'php';
$test_file = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'php';
$temp_skipif = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'skip.php';
$test_skipif = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'skip.php';
$temp_clean = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'clean.php';
$test_clean = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'clean.php';
$tmp_post = $temp_dir . DIRECTORY_SEPARATOR . uniqid('/phpt.');
$tmp_relative_file = str_replace(dirname(__FILE__) . DIRECTORY_SEPARATOR, '', $test_file) . 't';
if ($temp_source && $temp_target) {
$temp_skipif .= 's';
$temp_file .= 's';
$temp_clean .= 's';
$copy_file = $temp_dir . DIRECTORY_SEPARATOR . basename(is_array($file) ? $file[1] : $file) . '.phps';
if (!is_dir(dirname($copy_file))) {
@mkdir(dirname($copy_file), 0777, true) or error("Cannot create output directory - " . dirname($copy_file));
}
if (isset($section_text['FILE'])) {
save_text($copy_file, $section_text['FILE']);
}
$temp_filenames = array('file' => $copy_file, 'diff' => $diff_filename, 'log' => $log_filename, 'exp' => $exp_filename, 'out' => $output_filename, 'mem' => $memcheck_filename, 'php' => $temp_file, 'skip' => $temp_skipif, 'clean' => $temp_clean);
}
if (is_array($IN_REDIRECT)) {
$tested = $IN_REDIRECT['prefix'] . ' ' . trim($section_text['TEST']);
$tested_file = $tmp_relative_file;
$section_text['FILE'] = "# original source file: {$shortname}\n" . $section_text['FILE'];
}
// unlink old test results
@unlink($diff_filename);
@unlink($log_filename);
@unlink($exp_filename);
@unlink($output_filename);
@unlink($memcheck_filename);
@unlink($temp_file);
@unlink($test_file);
@unlink($temp_skipif);
@unlink($test_skipif);
@unlink($tmp_post);
@unlink($temp_clean);
@unlink($test_clean);
// Reset environment from any previous test.
$env['REDIRECT_STATUS'] = '';
$env['QUERY_STRING'] = '';
$env['PATH_TRANSLATED'] = '';
$env['SCRIPT_FILENAME'] = '';
$env['REQUEST_METHOD'] = '';
$env['CONTENT_TYPE'] = '';
$env['CONTENT_LENGTH'] = '';
if (!empty($section_text['ENV'])) {
foreach (explode("\n", $section_text['ENV']) as $e) {
$e = explode('=', trim($e));