php - 为什么 PHP 类在另一个脚本中运行良好时却在另一个脚本中找不到?
问题描述
我有两个脚本。两个脚本都位于同一服务器上的同一文件夹中。
脚本 1:
<?php
$text = "Is this not working? Why, yes it is.";
$locale = 'en_US';
$i = IntlBreakIterator::createSentenceInstance($locale);
$i->setText($text);
foreach($i->getPartsIterator() as $sentence) {
echo $sentence . PHP_EOL . '----- next -----' . PHP_EOL;
}
?>
脚本 2:
... bunch of other code ...
$doc = file_get_contents("file.txt");
$locale = 'en_US';
$i = IntlBreakIterator::createSentenceInstance($locale);
$i->setText($doc);
foreach($i->getPartsIterator() as $sentence) {
echo $sentence . PHP_EOL . '----- next -----' . PHP_EOL;
}
... bunch of other code ...
脚本 1 按预期执行,具有所需的输出且没有错误。脚本 2 不执行,PHP 不断抛出错误PHP Fatal error: Uncaught Error: Class 'IntlBreakIterator' not found
这里发生了什么?
解决方案
推荐阅读
- wordpress - 使用 https 的 Wordpress 随机缓慢加载时间
- java - 如何在 atomikos 全局事务管理器中优化提交
- angular - Angular Universal / Express:无法查找视图快递
- cxf - Apache CXF 打印定制的 SOAPEnvelope
- gmail-api - Gmail API 不支持新的线程 ID?
- azure - 应用之间的 Azure AD B2C SSO
- python - 当值为 json 字符串时,python json.loads() 失败
- reactjs - React 中的单元测试入口文件
- css - CSS Spinner Not Spinning
- r - 用 NA 替换字符(0)