gpt4 book ai didi

php - 谷歌翻译 Curl 在 php 5.3.8 中耗尽所有内存

转载 作者:可可西里 更新时间:2023-11-01 13:21:39 24 4
gpt4 key购买 nike

我一直在使用它来将基本站点文本翻译成不同的语言。在我更新到 PHP 5.3.8 之前它一直很好用。它耗尽了所有内存,完全关闭了我的服务器。我究竟做错了什么?我敢肯定,我会收到很多评论 :)

try {
$gt = new Gtranslate;
$gt->setRequestType('curl');

$SQL = "SELECT * FROM PAGE_CONTENT WHERE live_page = '1'";
$result = mysql_query($SQL);
while ($row = mysql_fetch_array($result)) {
$page_id_sub = $row["page_id"];
$page_title = $row["page_title"];
$page_permalink = $row["page_permalink"];

if (empty($mylang)) {
echo "<a href='/$permalink/$page_permalink.html'>$page_title</a> |";
} else {
$page_trans = $gt->$mylang("$page_title");
echo "<a href='/$permalink/$page_permalink.html'>$page_trans</a> |";
}
}
} catch (GTranslateException $ge) {
echo $ge->getMessage();
}

最佳答案

我会像这样调试以检查哪个进程卡住了。

<?php

echo "\n start: " . memory_get_usage() . "\n";

try{
$gt = new Gtranslate;
$gt->setRequestType('curl');

echo "\n after class: " . memory_get_usage() . "\n";

$SQL = "SELECT * FROM PAGE_CONTENT WHERE live_page = '1'";
$result = mysql_query( $SQL );

echo "\n after query: " . memory_get_usage() . "\n";

while( $row = mysql_fetch_array( $result ) ) {
$page_id_sub = $row["page_id"];
$page_title = $row["page_title"];
$page_permalink = $row["page_permalink"];

if(empty($mylang)){
echo "<a href='/$permalink/$page_permalink.html'>$page_title</a> |";
}
else {
$page_trans = $gt->$mylang("$page_title");
echo "<a href='/$permalink/$page_permalink.html'>$page_trans</a> |";
}
}
echo "\n after while: " . memory_get_usage() . "\n";

}
catch (GTranslateException $ge){
echo $ge->getMessage();
}

echo "\n end: " . memory_get_usage() . "\n";

关于php - 谷歌翻译 Curl 在 php 5.3.8 中耗尽所有内存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7897769/

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