phpinfo https://www.e-learn.cn/tag/phpinfo zh-hans Where does phpinfo() get its info? https://www.e-learn.cn/topic/4106961 <span>Where does phpinfo() get its info?</span> <span><span lang="" about="/user/150" typeof="schema:Person" property="schema:name" datatype="">只谈情不闲聊</span></span> <span>2021-02-16 16:20:44</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>If you run a <code>phpinfo();</code> does it show exactly what is in the php.ini or if settings are changed on the fly via php with methods like <code>ini_set()</code> or via <code>.htaccess</code> will they be shown in phpinfo?</p> <br /><h3>回答1:</h3><br /><p>phpinfo() shows, in the "<em>Local Value</em>" column, the current configuration ; i.e. </p> <ul><li>what is in <code>php.ini</code></li> <li>eventually, overriden in Apache's <code>VirtualHost</code> or in <code>.htaccess</code> files</li> <li>eventually, overriden by <code>ini_set</code></li> </ul><p>In the end, it shows the configuration values that would be / are used by your script.</p> <p><br /> As a sidenote : it also display informations that are not-really "configuration" per-se, like the configure line that was used to compile PHP, the version of the Zend Engine, ...</p> <br /><br /><br /><h3>回答2:</h3><br /><p>It will show the current running environment, not just what is in php.ini. Anything that changes the environment like the methods you mentioned will be reflected.</p> <br /><br /><br /><h3>回答3:</h3><br /><p>I think that's what the meaning of the "global" and "local" columns is - "global" is what's set in the central php.ini, "local" is whatever changes have been applied to the global setting using one of the methods you describe.</p> <br /><br /><br /><h3>回答4:</h3><br /><p>If you use <code>ini_set()</code>, the changes are made on-the-fly for the <strong>current</strong> script only, it does not permanently change <code>php.ini</code> settings. The <code>phpinfo()</code> shows current settings of what is there in the <code>php.ini</code> file which is also influenced by apache and <code>ini_set</code> function.</p> <br /><br /><br /><h3>回答5:</h3><br /><p><code>phpinfo()</code> always display the settings value in 2 column. First column is the global value that set in <code>php.ini</code> file. Second column is per user value, that set in <code>php.ini</code> or can be override by <code>.htaccess</code> file or override through <code>ini_set</code> before calling <code>phpinfo()</code>.</p> <p>Please note that not all settings value can be override by <code>.htaccess</code> or <code>ini_set</code>. See the complete list here and take a look at Changeable column. See the explanation og the Changeable column value here.</p> <p>Try it by yourself.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/2327830/where-does-phpinfo-get-its-info</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/php" hreflang="zh-hans">php</a></div> <div class="field--item"><a href="/tag/phpinfo" hreflang="zh-hans">phpinfo</a></div> </div> </div> Tue, 16 Feb 2021 08:20:44 +0000 只谈情不闲聊 4106961 at https://www.e-learn.cn memory_limit=80M. what is the maximum image size for imagecreateformjpeg()? https://www.e-learn.cn/topic/4073701 <span>memory_limit=80M. what is the maximum image size for imagecreateformjpeg()?</span> <span><span lang="" about="/user/12" typeof="schema:Person" property="schema:name" datatype="">倖福魔咒の</span></span> <span>2021-02-08 05:12:48</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>i have a webhosting that gives maximum memory_limit of 80M (i.e. ini_set("memory_limit","80M");). I'm using photo upload that uses the function imagecreatefromjpeg(); When i upload large images it gives the error "Fatal error: Allowed memory size of 83886080 bytes exhausted" What maximum size (in bytes) for the image i can restrict to the users? or the memory_limit depends on some other factor?</p> <br /><h3>回答1:</h3><br /><p>The memory size of <code>8388608</code> is 8 Megabytes, not 80. You may want to check whether you can still increase the value somewhere.</p> <p>Other than that, the general rule for image manipulation is that it will take at least</p> <pre><code>image width x image height x 3 </code></pre> <p>bytes of memory to load or create an image. (One byte for red, one byte for green, one byte for blue, possibly one more for alpha transparency)</p> <p>By that rule, a 640 x 480 pixel image will need at least 9.2 Megabytes of space - not including overhead and space occupied by the script itself.</p> <p>It's impossible to determine a limit on the JPG file size <em>in bytes</em> because JPG is a compressed format with variable compression rates. You will need to go by image resolution and set a limit on that. </p> <p>If you don't have that much memory available, you may want to look into more efficient methods of doing what you want, e.g. tiling (processing one part of an image at a time) or, if your provider allows it, using an external tool like ImageMagick (which consumes memory as well, but outside the PHP script's memory limit).</p> <br /><br /><br /><h3>回答2:</h3><br /><p>Probably your script uses more memory than the just the image itself. Trying debugging your memory consumption. </p> <p>One quick-and-dirty way is to utilize memory_get_usage and memory_get_usage memory_get_peak_usage on certain points in your code and especially in a custom error_handler and shutdown_function. This can let you know what exact operations causes the memory exhaustion.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/3382098/memory-limit-80m-what-is-the-maximum-image-size-for-imagecreateformjpeg</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/image" hreflang="zh-hans">image</a></div> <div class="field--item"><a href="/tag/php" hreflang="zh-hans">php</a></div> <div class="field--item"><a href="/tag/phpinfo" hreflang="zh-hans">phpinfo</a></div> <div class="field--item"><a href="/tag/memory-limit" hreflang="zh-hans">memory-limit</a></div> </div> </div> Sun, 07 Feb 2021 21:12:48 +0000 倖福魔咒の 4073701 at https://www.e-learn.cn memory_limit=80M. what is the maximum image size for imagecreateformjpeg()? https://www.e-learn.cn/topic/4073588 <span>memory_limit=80M. what is the maximum image size for imagecreateformjpeg()?</span> <span><span lang="" about="/user/206" typeof="schema:Person" property="schema:name" datatype="">十年热恋</span></span> <span>2021-02-08 05:04:56</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>i have a webhosting that gives maximum memory_limit of 80M (i.e. ini_set("memory_limit","80M");). I'm using photo upload that uses the function imagecreatefromjpeg(); When i upload large images it gives the error "Fatal error: Allowed memory size of 83886080 bytes exhausted" What maximum size (in bytes) for the image i can restrict to the users? or the memory_limit depends on some other factor?</p> <br /><h3>回答1:</h3><br /><p>The memory size of <code>8388608</code> is 8 Megabytes, not 80. You may want to check whether you can still increase the value somewhere.</p> <p>Other than that, the general rule for image manipulation is that it will take at least</p> <pre><code>image width x image height x 3 </code></pre> <p>bytes of memory to load or create an image. (One byte for red, one byte for green, one byte for blue, possibly one more for alpha transparency)</p> <p>By that rule, a 640 x 480 pixel image will need at least 9.2 Megabytes of space - not including overhead and space occupied by the script itself.</p> <p>It's impossible to determine a limit on the JPG file size <em>in bytes</em> because JPG is a compressed format with variable compression rates. You will need to go by image resolution and set a limit on that. </p> <p>If you don't have that much memory available, you may want to look into more efficient methods of doing what you want, e.g. tiling (processing one part of an image at a time) or, if your provider allows it, using an external tool like ImageMagick (which consumes memory as well, but outside the PHP script's memory limit).</p> <br /><br /><br /><h3>回答2:</h3><br /><p>Probably your script uses more memory than the just the image itself. Trying debugging your memory consumption. </p> <p>One quick-and-dirty way is to utilize memory_get_usage and memory_get_usage memory_get_peak_usage on certain points in your code and especially in a custom error_handler and shutdown_function. This can let you know what exact operations causes the memory exhaustion.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/3382098/memory-limit-80m-what-is-the-maximum-image-size-for-imagecreateformjpeg</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/image" hreflang="zh-hans">image</a></div> <div class="field--item"><a href="/tag/php" hreflang="zh-hans">php</a></div> <div class="field--item"><a href="/tag/phpinfo" hreflang="zh-hans">phpinfo</a></div> <div class="field--item"><a href="/tag/memory-limit" hreflang="zh-hans">memory-limit</a></div> </div> </div> Sun, 07 Feb 2021 21:04:56 +0000 十年热恋 4073588 at https://www.e-learn.cn different result between phpinfo.php and php-v https://www.e-learn.cn/topic/3213255 <span>different result between phpinfo.php and php-v</span> <span><span lang="" about="/user/38" typeof="schema:Person" property="schema:name" datatype="">|▌冷眼眸甩不掉的悲伤</span></span> <span>2020-01-14 09:37:46</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>i was using appserv 5.8 and in my phpinfo.php the php version was 5.6.26 now i installed laravel5.5 and its required phpversion 7 so i changed the php version to 7 from 5 now in my phpinfo.php</p> <pre><code>PHP Version 7.0.11 </code></pre> <p>and when i write in the command </p> <pre><code>php -v </code></pre> <p>its give me </p> <pre><code>PHP 5.6.26 (cli) (built: Sep 15 2016 18:12:07) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies </code></pre> <p>and i cant install the packages with laravel 5.5 bc the version in command line is 5.6 not 7 but when i check in phpinfo its 7 i have read something thats the command php -v tack the version from php-cli so how can i change the php -v to be 7.0.1 as phpinfo.php thanks .. </p> <br /><h3>回答1:</h3><br /><p>phpinfo.php shows what version of PHP Apache is using. -v shows what's in your $PATH. </p> <p>If you're on a Mac I recommend using homebrew to install php 7 as described here</p> <p>To clarify, PHP can be run in 3 ways: behind a web server, for command line scripting, and for GUI building. You have 2 versions: the web server one, which Apache is calling and invoking <code>phpinfo.php</code>, and PHP-CLI, which is invoked from the command line with <code>php -v</code>.</p> <br /><br /><br /><h3>回答2:</h3><br /><p>It seems like your PHP CLI version is different than the PHP web version. Upgrade your PHP CLI package.</p> <br /><br /><br /><h3>回答3:</h3><br /><p>You have two PHP binaries installed. In my Mac OSX:</p> <pre><code>$ which php /usr/local/bin/php $ /usr/local/bin/php -v PHP 7.0.20 (cli) (built: Jul 12 2017 09:47:44) ( NTS ) </code></pre> <p>And in same machine:</p> <pre><code>$ whereis php /usr/bin/php $ /usr/bin/php -v PHP 5.6.30 (cli) (built: Feb 7 2017 16:18:37) </code></pre> <p>You should put /usr/local/bin in your PATH. Edit ~/.bash_profile</p> <pre><code>export PATH=/usr/local/bin:/usr/local/sbin:$PATH </code></pre> <p>Open a new terminal and check your php version.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/46018531/different-result-between-phpinfo-php-and-php-v</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/phpinfo" hreflang="zh-hans">phpinfo</a></div> </div> </div> Tue, 14 Jan 2020 01:37:46 +0000 |▌冷眼眸甩不掉的悲伤 3213255 at https://www.e-learn.cn How to get phpinfo() variables from php programmatically? https://www.e-learn.cn/topic/3031414 <span>How to get phpinfo() variables from php programmatically?</span> <span><span lang="" about="/user/15" typeof="schema:Person" property="schema:name" datatype="">假装没事ソ</span></span> <span>2020-01-01 02:26:10</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I am attempting to get a list of dependable(consistent across requests) list of "hidden" constants in PHP(as in, the client-side won't know about it in most cases without hacking). </p> <p>Some of the things I am interested in is the following:</p> <ol><li><code>./configure</code> options.</li> <li>I would also like the very first <code>System</code> value in phpinfo. </li> <li>The loaded PHP modules(as shown in the Apache section)</li> <li>The build date of PHP.</li> <li>Registered PHP streams</li> <li>Registered stream socket transports</li> <li>Registered stream filters</li> </ol><p>How can I get either just a portion of the phpinfo or get these values as a regular string? Note that it doesn't matter if there if markup included, but I don't want to parse the phpinfo as that just seems really slow and surely there is a better way.. </p> <br /><h3>回答1:</h3><br /><p>Here you go:</p> <ol><li><code>ini_get_all()</code> or <code>get_loaded_extensions()</code> <strong>were the closest I could find</strong></li> <li><code>php_uname()</code></li> <li><code>apache_get_modules()</code></li> <li><code>phpversion()</code> <strong>was the closest I could find</strong></li> <li><code>stream_get_wrappers()</code></li> <li><code>stream_get_transports()</code></li> <li><code>stream_get_filters()</code></li> </ol><p>See also <code>get_defined_constants()</code> and some more.</p> <hr /><p>As Chacha102 mentioned you can also use output control functions and parse the <code>phpinfo()</code>:</p> <pre><code>ob_start(); phpinfo(); $variable = ob_get_contents(); ob_get_clean(); </code></pre> <p>Due to the use of <code>ob_get_clean()</code> it won't mess up other output buffering levels you may be using.</p> <br /><br /><br /><h3>回答2:</h3><br /><p>Most of the stuff available from phpinfo() can be found in constants. Try looking through:</p> <pre><code>print_r(get_defined_constants()); </code></pre> <p>Or the functions on this page: http://us.php.net/manual/en/ref.info.php. There are tons of functions to get information about specific extensions.</p> <p>The following functions might be worth looking at:</p> <p><code>ini_get()</code> http://us.php.net/manual/en/function.ini-get.php<br /><code>getenv()</code> http://us.php.net/manual/en/function.getenv.php<br /><code>get_cfg_var()</code> http://us.php.net/manual/en/function.get-cfg-var.php </p> <br /><br /><br /><h3>回答3:</h3><br /><p>Maybe I am late a bit, but basically if you call a shell script problematically to the php.exe</p> <pre><code>php -i </code></pre> <p>then you can parse all the information required</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/2069364/how-to-get-phpinfo-variables-from-php-programmatically</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/php" hreflang="zh-hans">php</a></div> <div class="field--item"><a href="/tag/configuration" hreflang="zh-hans">configuration</a></div> <div class="field--item"><a href="/tag/phpinfo" hreflang="zh-hans">phpinfo</a></div> </div> </div> Tue, 31 Dec 2019 18:26:10 +0000 假装没事ソ 3031414 at https://www.e-learn.cn PHP disable_functions in .user.ini file gives “no value” in phpinfo() output https://www.e-learn.cn/topic/2878169 <span>PHP disable_functions in .user.ini file gives “no value” in phpinfo() output</span> <span><span lang="" about="/user/139" typeof="schema:Person" property="schema:name" datatype="">删除回忆录丶</span></span> <span>2019-12-24 11:52:25</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I put the following code in .user.ini file under apache virtual host document root. And when I view the phpinfo() output, the disable_functions fields says "no value". Please help me to figure out why. </p> <p>(The "memory_limit" and "max_execution_time" are setting correctly.)</p> <p>Thanks in advance.</p> <pre><code>memory_limit = 2048M max_execution_time = 3600 disable_functions = apache_child_terminate,apache_get_modules,apache_getenv,apache_note,apache_setenv,curl_multi_exec,define_syslog_variables,disk_free_space,diskfreespace,dl,fpassthru,ftp_connect,ftp_exec,ftp_get,ftp_login,ftp_nb_fput,ftp_put,ftp_raw,ftp_rawlist,get_current_user,getmyuid,highlight_file,ini_alter,ini_get_all,ini_restore,link,ini_set,mysql_list_dbs,openlog,parse_ini_file,passthru,pclose,pcntl_exec,pfsockopen,php_uname,pcntl_alarm,pcntl_fork,pcntl_get_last_error,pcntl_signal,pcntl_getpriority,pcntl_setpriority,pcntl_strerror,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_waitpid,pcntl_wait,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,popen,posix_getgrgid,posix_getpwuid,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,posix_setuid,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,socket_accept,socket_bind,socket_create,socket_create_listen,socket_create_pair,socket_listen,shell_exec,show_source,socket_select,socket_strerror,stream_select,syslog,symlink,system </code></pre> <br /><h3>回答1:</h3><br /><p>@Charles is right, the PHP Manual clearly states that <em>disable_functions</em> can only be set in the master <em>php.ini</em>. This clearly defeats per-vhost custom value.</p> <p>There's a workaround for this if you have uopz PECL extension enabled. Check my other answer for details.</p> <br /><br /><br /><h3>回答2:</h3><br /><p>You need to enclose that with "</p> <pre><code>disable_functions = "apache_child_terminate,apache_get_modules,apache_getenv,apache_note,apache_setenv,curl_multi_exec,define_syslog_variables,disk_free_space,diskfreespace,dl,fpassthru,ftp_connect,ftp_exec,ftp_get,ftp_login,ftp_nb_fput,ftp_put,ftp_raw,ftp_rawlist,get_current_user,getmyuid,highlight_file,ini_alter,ini_get_all,ini_restore,link,ini_set,mysql_list_dbs,openlog,parse_ini_file,passthru,pclose,pcntl_exec,pfsockopen,php_uname,pcntl_alarm,pcntl_fork,pcntl_get_last_error,pcntl_signal,pcntl_getpriority,pcntl_setpriority,pcntl_strerror,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_waitpid,pcntl_wait,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,popen,posix_getgrgid,posix_getpwuid,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,posix_setuid,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,socket_accept,socket_bind,socket_create,socket_create_listen,socket_create_pair,socket_listen,shell_exec,show_source,socket_select,socket_strerror,stream_select,syslog,symlink,system" </code></pre> <br /><br /><br /><h3>回答3:</h3><br /><p>I just looked at the php.ini derective page carefully and I found <code>disable_function</code>'s changeable field is <code>php.ini only</code>. So it will only be changed inside the global php.ini file. And I am afraid that I have to find another way to implement my requirement. If anybody can give me some suggestion about how to assign different disable_functions list to different apache vritual hosts, that will be super helpful. Cheers.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/24387209/php-disable-functions-in-user-ini-file-gives-no-value-in-phpinfo-output</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/php" hreflang="zh-hans">php</a></div> <div class="field--item"><a href="/tag/php-ini" hreflang="zh-hans">php-ini</a></div> <div class="field--item"><a href="/tag/phpinfo" hreflang="zh-hans">phpinfo</a></div> </div> </div> Tue, 24 Dec 2019 03:52:25 +0000 删除回忆录丶 2878169 at https://www.e-learn.cn Install PDFlib on XAMPP OS X 10.13.5 https://www.e-learn.cn/topic/2858349 <span>Install PDFlib on XAMPP OS X 10.13.5</span> <span><span lang="" about="/user/75" typeof="schema:Person" property="schema:name" datatype="">六月ゝ 毕业季﹏</span></span> <span>2019-12-24 06:33:16</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I need to install PDFlib required for one module build for a magento website. What I did so far is:</p> <ol><li>go to https://www.pdflib.com/download/pdflib-product-family/ and download the latest version for OS X.</li> <li>print out a phpinfo to find out my extension_dir path /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20131226 </li> <li>copy the the php_pdflib.so in the extension_dir folder</li> <li>open /Applications/XAMPP/xampfiles/etc/php.ini and put the following extension=php_pdflib.so </li> <li>restart apache</li> <li>check in the phpinfo - nothing there</li> <li>run php -m and php -i from terminal and PDFlib is listed</li> </ol><p>I even try installing with the brew command</p> <p>What I've done wrong?</p> <p>来源:<code>https://stackoverflow.com/questions/53784171/install-pdflib-on-xampp-os-x-10-13-5</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/php" hreflang="zh-hans">php</a></div> <div class="field--item"><a href="/tag/pdf" hreflang="zh-hans">pdf</a></div> <div class="field--item"><a href="/tag/xampp" hreflang="zh-hans">xampp</a></div> <div class="field--item"><a href="/tag/phpinfo" hreflang="zh-hans">phpinfo</a></div> </div> </div> Mon, 23 Dec 2019 22:33:16 +0000 六月ゝ 毕业季﹏ 2858349 at https://www.e-learn.cn PHP Fatal error Out of memory https://www.e-learn.cn/topic/2789552 <span>PHP Fatal error Out of memory</span> <span><span lang="" about="/user/22" typeof="schema:Person" property="schema:name" datatype="">江枫思渺然</span></span> <span>2019-12-23 04:07:09</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I am calling the below two function inside a function called RebuildSummary()</p> <ol><li>create_summary()</li> <li>insertdatafromfile()</li> </ol><h1>1. create_summary function</h1> <p>create_summary function fetches activity data from database and loop through activities using for each loop, and insert data into the below text file like below:</p> <h1>zfilename71801404123.txt</h1> <pre><code>A|201309|R|C|2|014000956|014000956|2200|201211|M|3118.72|35215.12|1639.96|40749.29|46183.13|44653.83|1529.3|||423|9999|EVERGREEN IMPLEMENT INC A|201309|R|C|2|014000956|014000956|2201|201211|M|0|13.86|0|15.22|13.86|15.22|-1.36|||423|9999|EVERGREEN IMPLEMENT INC </code></pre> <h1>2. insertdatafromfile function</h1> <p>insertdatafromfile function will read the contents of the same text file[zfilename71801404123.txt] and insert them into the summary table using the command LOAD DATA.</p> <h1>Code</h1> <pre><code>function RebuildSummary() { $random = date('dmyhis'); $zfilename = "zfilename".$random; create_summary($zfilename); insertdata($zfilename); } function create_summary($zfilename) { $activities // data from DB $filepath = $_SERVER['DOCUMENT_ROOT']."\z".$zfilename.".txt"; foreach ($activities as $activity) { $sql_summary = "SELECT A.AcctDb as AcctDb, '" . $default-&gt;DeftReportPeriod . "' as SumReportPer, '" . $default-&gt;DeftReportBase . "' as SumReportBase, '" . $default-&gt;DeftPeriodBasis . "' as SumPeriodBasis, '" . $default-&gt;DeftBasisAdj . "' as SumBasisAdj, '" . $AcctNo . "' as AcctNo,'" . $AcctTaxId . "' as AcctTaxId, '" . $RevLoc . "' as SumRevLoc, '" . $YTDStart . "' as SumYtdStart, '" . $CurrFreq . "' as SumCurrFreq, '" . $Curr . "' as SumCurrAmt, '" . $Ytd . "' as SumYtdAmt, '" . $Lastcurr . "' as SumLastCurr, '" . $LastYTD . "' as SumLastYtd, '" . $Last12 . "' as SumLast12, '" . $Prior12 . "' as SumPrior12, '" . $Last12diff . "' as SumLast12Diff, A.AcctDateOpen as SumDateOpen, A.AcctDateClosed as SumDateClosed, A.GroupCode as SumGroupCode, A.AcctHomeLoc as SumHomeLoc, A.AcctBusName as SumBusName, A.ClassCode as SumClassCode, '" . $Currdiff . "' asSumCurrDiff, '" . $Ytddiff . "' as SumYtdDiff, '" . $Mon['0'] . "' as SumMon01, '" . $Mon['1'] . "' as SumMon02, '" . $Mon['2'] . "' as SumMon03, '" . $Mon['3'] . "' as SumMon04, '" . $Mon['4'] . "' as SumMon05, '" . $Mon['5'] . "' as SumMon06, '" . $Mon['6'] . "' as SumMon07, '" . $Mon['7'] . "' as SumMon08, '" . $Mon['8'] . "' as SumMon09, '" . $Mon['9'] . "' as SumMon10, '" . $Mon['10'] . "' as SumMon11, '" . $Mon['11'] . "' as SumMon12,'" . $Amt['0'] . "' as SumAmt01, '" . $Amt['1'] . "' as SumAmt02, '" . $Amt['2'] . "' as SumAmt03,'" . $Amt['3'] . "' as SumAmt04, '" . $Amt['4'] . "' as SumAmt05, '" . $Amt['5'] . "' as SumAmt06, '" . $Amt['6'] . "' as SumAmt07, '" . $Amt['7'] . "' as SumAmt08, '" . $Amt['8'] . "' as SumAmt09, '" . $Amt['9'] . "' as SumAmt10, '" . $Amt['10'] . "' as SumAmt11, '" . $Amt['11'] . "' as SumAmt12 FROM accounts A WHERE A.AcctDb = '" . $AcctDb . "' and A.AcctTaxId='" . $AcctTaxId . "' ;"; $exist_activity1 = $this-&gt;db-&gt;query($sql_summary); $activities1 = $exist_activity1-&gt;result_array(); $flag_index = 0; foreach ($activities1[0] as $key =&gt; $value) { if ($flag_index == 0) { } $result .= $value . "|"; $flag_index = 1; } $j++; $result = rtrim($result, "|"); $handle = fopen($filepath, 'a') or die('Cannot open file: ' . $filepath); fwrite($handle, $result); $new_data = "\n"; fwrite($handle, $new_data); $result = ""; } } function insertdatafromfile($zfilename) { ini_set('memory_limit', '-1'); $ext = mysql_real_escape_string("\n"); $filepath = "z".$zfilename.".txt"; $sqlstatement1 = "LOAD DATA INFILE " . "'" . $filepath . "'" . " INTO TABLE summary FIELDS TERMINATED BY '|' LINES TERMINATED BY " . "'" . $ext . "'" . " (AcctDb, SumReportPer, SumReportBase, SumPeriodBasis, SumBasisAdj, AcctNo,AcctTaxId, SumRevLoc, SumYtdStart, SumCurrFreq, SumCurrAmt, SumYtdAmt, SumLastCurr, SumLastYtd, SumLast12, SumPrior12, SumLast12Diff, SumDateOpen, SumDateClosed, SumGroupCode, SumHomeLoc, SumBusName, SumClassCode, SumCurrDiff, SumYtdDiff, SumMon01, SumMon02, SumMon03, SumMon04, SumMon05, SumMon06, SumMon07, SumMon08, SumMon09, SumMon10, SumMon11, SumMon12, SumAmt01, SumAmt02, SumAmt03, SumAmt04, SumAmt05, SumAmt06, SumAmt07, SumAmt08, SumAmt09, SumAmt10, SumAmt11, SumAmt12) "; mysql_query($sqlstatement1); $filepath = $_SERVER['DOCUMENT_ROOT']."\z".$zfilename.".txt"; unlink($filepath); } </code></pre> <h1>System Configuration:</h1> <pre><code>Processor: Intel(R) Xeon(TM) CPU 2.80Ghz, 2.79 Ghz (2 Processors) Installed memory(RAM) : 6.00 GB System Type: 64 bit Operating System Server: Windows IIS 7 </code></pre> <h1>PHPINFO</h1> <pre><code>max_input_time: 60000 max_file_uploads: 2048M memory_limit: 20000M post_max_size: 20000M upload_max_filesize: 15000M </code></pre> <h1>My Question:</h1> <p>I am getting the below error while calling the RebuildSummary function.</p> <pre><code>[17-Apr-2014 03:54:42 America/Los_Angeles] PHP Fatal error: Out of memory (allocated 1517289472) (tried to allocate 64 bytes) in C:\HostingSpaces\wwwroot\system\database\drivers\mysql\mysql_result.php on line 162 </code></pre> <p>I have enough memory on server side, still how the system display this error "Out of memory"</p> <br /><h3>回答1:</h3><br /><p><code>1517289472 bytes ~= 1.4G</code> so you're hitting a barrier around there</p> <p>The first thing you should look at is you're setting <code>memory_limit: 20000M</code> which is 20G. You've only 6G on your system. PHP may be confused and defaulting to a lower limit or there may be a hard limit for your version of php running on windows 7.</p> <p>OR you could be running 32 bit Apache/PHP processes, which have hard limits around 2G see this: Upper memory limit for PHP/Apache</p> <br /><br /><br /><h3>回答2:</h3><br /><p>if you're going through a tonne of data, do not use <code>fetch_all()</code> which is what I'm assuming you are using within your database class.</p> <p>you should fetch each record individually, e.g.:</p> <pre><code>while ($row = mysqli_fetch_array($link)) { // insert row into file } </code></pre> <p>here is a simple benchmark someone did before to illustrate the difference in memory usage: https://stackoverflow.com/a/2771563/520857</p> <p>spoiler: 100Mb vs 400bytes</p> <br /><br /><br /><h3>回答3:</h3><br /><p>Doesn't matter how much ram you allow for PHP. If it's a 32bit-compile, it could never use more than 4gig utter max, and practical ~3gig.</p> <p>As for your code, you're sucking in your ENTIRE database result into ram, then building a string (essentially doubling memory requirements), then dumping that string out to file. Since you're obviously running out of memory, you'll have to stream the string, e.g.</p> <pre><code>$fh = fopen(...); $separator = ''; while($row = fetch_from_db()) { fwrite($fh, $sep . $row[0]); $separator = '|'; } </code></pre> <p>This is somewhat inefficient, but should be enough to give you the general idea. A more efficient solution would be to build a LIMITED length string and write it out periodically. e.g. when your concatentated string reaches (say) 1 meg in size, you write it out and then reset the string to empty.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/23132890/out-of-memory-load-data-infile</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/mysql" hreflang="zh-hans">mysql</a></div> <div class="field--item"><a href="/tag/fatal-error" hreflang="zh-hans">fatal-error</a></div> <div class="field--item"><a href="/tag/phpinfo" hreflang="zh-hans">phpinfo</a></div> </div> </div> Sun, 22 Dec 2019 20:07:09 +0000 江枫思渺然 2789552 at https://www.e-learn.cn $_SERVER['REQUEST_METHOD'] does not exist https://www.e-learn.cn/topic/2664348 <span>$_SERVER[&#039;REQUEST_METHOD&#039;] does not exist</span> <span><span lang="" about="/user/51" typeof="schema:Person" property="schema:name" datatype="">大兔子大兔子</span></span> <span>2019-12-20 03:59:14</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I've just installed WAMP and I can access localhost and get the phpinfo() output.</p> <p>However, although I can see _SERVER['REQUEST_METHOD'] is set to GET, I'm trying to use the following PHP:</p> <pre><code>if ($_SERVER["REQUEST_METHOD"]=="POST") { ... </code></pre> <p>but it produces this error:</p> <blockquote> <p>PHP Notice: Undefined index: REQUEST_METHOD in C:\ ... \test.php on line 40</p> </blockquote> <p>Using Komodo to stop at line 40 and check $_SERVER - it does not have 'REQUEST_METHOD' in the array at all - not even GET.</p> <p>Anyone have any ideas? Do I have to enable POST, REQUEST_METHOD?</p> <p>Why can I see REQUEST_METHOD=GET in the phpinfo but not in the PHP script.</p> <p>I also tried this:</p> <pre><code>&lt;?php ob_start(); phpinfo(); $info = ob_get_contents(); ob_end_clean(); ?&gt; </code></pre> <p>I generates some of the phpinfo (as viewed in the browser using localhost/?phpinfo=1) but not all of it. Why not?</p> <br /><h3>回答1:</h3><br /><p>Most $_SERVER directives are set by the web server. If you are using WAMP that would be Apache. You can check your apache config to find out why this value isn't set.</p> <p>It's better to test for the existence of values before trying to use them.</p> <pre><code>$value = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null; </code></pre> <p>You can even use the getenv() method to shorten this.</p> <pre><code>$value = getenv('REQUEST_METHOD'); </code></pre> <p>Also there is no need to do</p> <pre><code>&lt;?php ob_start(); phpinfo(); $info = ob_get_contents(); ob_end_clean(); ?&gt; </code></pre> <p>This is all you need in a blank PHP file.</p> <pre><code>&lt;?php phpinfo(); </code></pre> <p>I would write your example like this:</p> <pre><code>$request_method = strtoupper(getenv('REQUEST_METHOD')); $http_methods = array('GET', 'POST', 'PUT', 'DELETE', 'HEAD', 'OPTIONS'); if( ! in_array($request_method, $http_methods) { die('invalid request'); } </code></pre> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/12754388/serverrequest-method-does-not-exist</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/php" hreflang="zh-hans">php</a></div> <div class="field--item"><a href="/tag/phpinfo" hreflang="zh-hans">phpinfo</a></div> </div> </div> Thu, 19 Dec 2019 19:59:14 +0000 大兔子大兔子 2664348 at https://www.e-learn.cn phpinfo() is not working on my CentOS server https://www.e-learn.cn/topic/2611372 <span>phpinfo() is not working on my CentOS server</span> <span><span lang="" about="/user/140" typeof="schema:Person" property="schema:name" datatype="">你说的曾经没有我的故事</span></span> <span>2019-12-18 13:04:11</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I have PHP installed on my CentOS server. However, when running a phpinfo() inside my script to test it, I receive the HTML, not the interpreted information.</p> <p>I can see the folders for PHP. I can even see the php.ini in the <code>etc</code> folder. But PHP itself does not seem to be working.</p> <p>I mean my test.php file looks like this:</p> <pre><code>&lt;?php phpinfo(); ?&gt; </code></pre> <p>And the response looks like this:</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"&gt; &lt;html&gt;&lt;head&gt; &lt;style type="text/css"&gt; body {background-color: #ffffff; color: #000000;} body, td, th, h1, h2 {font-family: sans-serif;} pre {margin: 0px; font-family: monospace;} a:link {color: #000099; text-decoration: none; background-color: #ffffff;} ... </code></pre> <p>and so on.</p> <p>What seems to be the problem and how do I solve it?</p> <p>If I copy the HTML returned, paste it into an HTML file, and run it from there, I can see the formatted result, but not by running the test.php. I assume PHP is not loaded somehow... even if in the interpreted HTML I can see the:</p> <pre><code>**Server API Apache 2.0 Handler Virtual Directory Support disabled Configuration File (php.ini) Path /etc/php.ini Scan this dir for additional .ini files /etc/php.d additional .ini files parsed /etc/php.d/dbase.ini, /etc/php.d/json.ini, /etc/php.d/mysql.ini, /etc/php.d/mysqli.ini, /etc/php.d/pdo.ini, /etc/php.d/pdo_mysql.ini, /etc/php.d/pdo_sqlite.ini PHP API 20041225 PHP Extension 20050922 Zend Extension 220051025 Debug Build no Thread Safety disabled Zend Memory Manager enabled IPv6 Support enabled Registered PHP Streams php, file, http, ftp, compress.bzip2, compress.zlib, https, ftps** </code></pre> <p>and so on...</p> <p>On this system, there are three websites hosted. Does that have anything to do with this problem?</p> <br /><h3>回答1:</h3><br /><p>This happened to me as well. The fix was wrapping it in HTML tags. Then I saved the file as <strong>/var/www/html/info.php</strong> and ran http://localhost/info.php in the browser. That's it.</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;?php phpinfo(); ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <br /><br /><br /><h3>回答2:</h3><br /><p>Save the page which contains </p> <pre><code>&lt;?php phpinfo(); ?&gt; </code></pre> <p>with the .php extension. Something like <code>info.php</code>, not <code>info.html</code>...</p> <br /><br /><br /><h3>回答3:</h3><br /><p>You need to update your Apache configuration to make sure it's outputting <code>php</code> as the type text/HTML.</p> <p>The below code should work, but some configurations are different.</p> <pre><code>AddHandler php5-script .php AddType text/html .php </code></pre> <br /><br /><br /><h3>回答4:</h3><br /><p>This did it for me (the second answer): <em>Why are my PHP files showing as plain text?</em></p> <p>Simply adding this, nothing else worked.</p> <pre><code>apt-get install libapache2-mod-php5 </code></pre> <br /><br /><br /><h3>回答5:</h3><br /><p>I just had the same issue and found that a client had disabled this function from their <code>php.ini</code> file:</p> <pre><code>; This directive allows you to disable certain functions for security reasons. ; It receives a comma-delimited list of function names. This directive is ; *NOT* affected by whether Safe Mode is turned On or Off. disable_functions = phpinfo; </code></pre> <p>More information: Enabling and disabling phpinfo() for security reasons</p> <br /><br /><br /><h3>回答6:</h3><br /><p>Try to create a <code>php.ini</code> file in root and write the following command in and save it.</p> <pre><code>disable_functions = </code></pre> <p>Using this code will enable the phpinfo() function for you if it is disabled by the global PHP configuration.</p> <br /><br /><br /><h3>回答7:</h3><br /><p>Be sure that the tag "php" is stick in the code like this:</p> <p><strong>?php</strong> phpinfo(); ?&gt;</p> <p><strong>Not like</strong> this:</p> <p><strong>? php</strong> phpinfo(); ?&gt;</p> <p><strong>OR the server will treat it as a (normal word), so the server will not understand the language you are writing to deal with it so it will be blank</strong>.</p> <p>I know it's a silly error ...but it happened ^_^</p> <br /><br /><br /><h3>回答8:</h3><br /><p>My solution was uninstalling and installing the PHP instance (7.0 in my case) again:</p> <pre><code>sudo apt-get purge php7.0 sudo apt-get install php7.0 </code></pre> <p>After that you will need to restart the Apache service:</p> <pre><code>sudo service apache2 restart </code></pre> <p>Finally, verify again in your browser with your localhost or IP address.</p> <br /><br /><br /><h3>回答9:</h3><br /><p>For people who have no experience in building websites (like me) I tried a lot, only to find out that I hadn't used the <code>.php</code> extension, but the <code>.html</code> extension.</p> <br /><br /><br /><h3>回答10:</h3><br /><p>I accidentally set the wrong file permissions. After <code>chmod 644 phpinfo.php</code> the info indeed showed up as expected.</p> <br /><br /><br /><h3>回答11:</h3><br /><p>It may not work for you if you use <code>localhost/info.php</code>.</p> <p>You may be able to found the clue from the error. Find the port number in the error message. To me it was 80. I changed address as http://localhost:80/info.php, and then it worked to me.</p> <br /><br /><br /><h3>回答12:</h3><br /><p>It happened to me as well. On a newly provisioned Red Hat Linux 7 server.</p> <p>When I run a PHP page, i.e. info.php, I could see plain text PHP scripts instead of executing them.</p> <p>I just installed PHP:</p> <pre><code>[root@localhost ~]# yum install php </code></pre> <p>And then restarted Apache HTTP Server:</p> <pre><code>[root@localhost ~]# systemctl restart httpd </code></pre> <br /><br /><br /><h3>回答13:</h3><br /><p>I had the same problem.</p> <p>The solution in my case was to set <strong>default_mimetype = "text/html"</strong> inside the <em>php.ini</em> file.</p> <br /><br /><br /><h3>回答14:</h3><br /><p>Another possible answer for Windows 10:</p> <p>The command <code>httpd -k restart</code> does <strong>not</strong> work on my machine somehow.</p> <p>Try to use the Windows 10 <strong>Service</strong> to restart the relative service.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/17778264/phpinfo-is-not-working-on-my-centos-server</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/php" hreflang="zh-hans">php</a></div> <div class="field--item"><a href="/tag/centos" hreflang="zh-hans">CentOS</a></div> <div class="field--item"><a href="/tag/phpinfo" hreflang="zh-hans">phpinfo</a></div> </div> </div> Wed, 18 Dec 2019 05:04:11 +0000 你说的曾经没有我的故事 2611372 at https://www.e-learn.cn