我有两个运行相同php脚本的cpanel网站,用于解析csv文件,一个在godaddy服务器上(站点A),一个在hostgator上(站点B)。在站点B上,页面的html部分呈现然后它解析csv,而在站点A上它解析csv然后呈现html部分。
为什么会出现这种不同的行为?我想让Site A像Site B一样执行这个脚本
他们都运行php 5.4并且具有相同的执行时间限制。
以下是php.ini数组name =>的array_diff_assoc的结果。 local_value。第一个是array_diff_assoc(站点B,站点A),第二个是array_diff_assoc(站点A,站点B)
Array
(
[allow_url_include] => 1
[date.timezone] => America/Chicago
[disable_functions] => dl
[enable_dl] =>
[error_reporting] => 22519
[expose_php] =>
[extension_dir] => /opt/php54/lib/php/extensions/no-debug-non-zts-20100525
[include_path] => .:/opt/php54/lib/php
[intl.default_locale] =>
[intl.error_level] => 0
[max_execution_time] => 30
[memory_limit] => 256M
[mssql.allow_persistent] => 1
[mssql.batchsize] => 0
[mssql.charset] =>
[mssql.compatability_mode] =>
[mssql.connect_timeout] => 5
[mssql.datetimeconvert] => 1
[mssql.max_links] => -1
[mssql.max_persistent] => -1
[mssql.max_procs] => -1
[mssql.min_error_severity] => 10
[mssql.min_message_severity] => 10
[mssql.secure_connection] =>
[mssql.textlimit] => -1
[mssql.textsize] => -1
[mssql.timeout] => 60
[mysql.allow_persistent] =>
[odbc.allow_persistent] =>
[odbc.check_persistent] =>
[odbc.default_cursortype] => 3
[odbc.default_db] =>
[odbc.default_pw] =>
[odbc.default_user] =>
[odbc.defaultbinmode] => 1
[odbc.defaultlrl] => 4096
[odbc.max_links] => -1
[odbc.max_persistent] => -1
[pcre.backtrack_limit] => 1000000
[pcre.recursion_limit] => 100000
[post_max_size] => 64M
[sourceguardian.restrict_unencoded] => 0
[upload_max_filesize] => 64M
[xsl.security_prefs] => 44
)
Array
(
[allow_url_include] => 0
[apc.cache_by_default] => 1
[apc.canonicalize] => 1
[apc.coredump_unmap] => 0
[apc.enable_cli] => 0
[apc.enabled] => 1
[apc.file_md5] => 0
[apc.file_update_protection] => 2
[apc.filters] =>
[apc.gc_ttl] => 3600
[apc.include_once_override] => 0
[apc.lazy_classes] => 0
[apc.lazy_functions] => 0
[apc.max_file_size] => 1M
[apc.mmap_file_mask] =>
[apc.num_files_hint] => 1000
[apc.preload_path] =>
[apc.report_autofilter] => 0
[apc.rfc1867] => 0
[apc.rfc1867_freq] => 0
[apc.rfc1867_name] => APC_UPLOAD_PROGRESS
[apc.rfc1867_prefix] => upload_
[apc.rfc1867_ttl] => 3600
[apc.serializer] => default
[apc.shm_segments] => 1
[apc.shm_size] => 32M
[apc.shm_strings_buffer] => 4M
[apc.slam_defense] => 1
[apc.stat] => 1
[apc.stat_ctime] => 0
[apc.ttl] => 0
[apc.use_request_time] => 1
[apc.user_entries_hint] => 4096
[apc.user_ttl] => 0
[apc.write_lock] => 1
[date.timezone] => UTC
[disable_functions] =>
[enable_dl] => 1
[error_reporting] => 1
[expose_php] => 1
[extension_dir] => /usr/local/lib/php/extensions/no-debug-non-zts-20100525
[include_path] => .:/usr/lib/php:/usr/local/lib/php
[max_execution_time] => 120
[memory_limit] => 64M
[mysql.allow_persistent] => 1
[mysqlnd.collect_memory_statistics] => 0
[mysqlnd.collect_statistics] => 1
[mysqlnd.debug] =>
[mysqlnd.log_mask] => 0
[mysqlnd.mempool_default_size] => 16000
[mysqlnd.net_cmd_buffer_size] => 4096
[mysqlnd.net_read_buffer_size] => 32768
[mysqlnd.net_read_timeout] => 31536000
[pcre.backtrack_limit] => 10000000
[pcre.recursion_limit] => 10000000
[post_max_size] => 48M
[upload_max_filesize] => 32M
)
更新1
在比较ini_get_all时,我发现站点A启用了APC,而站点B没有...这可能是问题吗?在禁用APC时,此实现是否有任何损害?
更新2
我相信我们可以排除implicit_flush,因为两者都设置为false并且将站点A设置为true不会改变行为
更新3
包含ini文件的差异
更新4
我已将网站A的php.ini文件设置为与网站B相同,但行为没有变化,所以我们可以将其排除在外吗?
更新5
虽然它不能模仿站点B的异步性质,但使用
ob_flush();
flush();
刷新缓冲区似乎非常接近,但它不是一个非常干净的解决方案...