【问题标题】:PHP file not displaying anything?PHP文件不显示任何内容?
【发布时间】:2016-01-26 09:13:32
【问题描述】:

我有当前代码,它只有在我注释掉函数时才有效。帮助? 它不显示标题标签或任何东西。我在想这是我缺少的一些语法,但还没有看到它。

<html>
<head>
<title>Convert to Roman</title>
</head>
<body>
<?php
function integerToRoman($integer)
{
 // Convert the integer into an integer (just to make sure)
 $integer = intval($integer);
 $result = '';

 // Create a lookup array that contains all of the Roman numerals.
 $lookup = array('M' => 1000,
 'CM' => 900,
 'D' => 500,
 'CD' => 400,
 'C' => 100,
 'XC' => 90,
 'L' => 50,
 'XL' => 40,
 'X' => 10,
 'IX' => 9,
 'V' => 5,
 'IV' => 4,
 'I' => 1);

 foreach($lookup as $roman => $value){
  // Determine the number of matches
  $matches = intval($integer/$value);

  // Add the same number of characters to the string
  $result .= str_repeat($roman,$matches);

  // Set the integer to be the remainder of the integer and the value
  $integer = $integer % $value;
 }

 // The Roman numeral should be built, return it
 return $result;
}
echo integerToRoman(5);
?>
</body>
</html>

【问题讨论】:

  • error_reporting(E_ALL);
  • 试过了。那只是在
  • 它工作正常...在这里查看演示sandbox.onlinephpfunctions.com/code/…
  • 你的文件扩展名是什么??
  • 由于某种原因它不会出现在我的浏览器中。有什么提示吗?我运行了 LAMP 并检查了所有 php 先决条件。

标签: php


【解决方案1】:

要使其正常工作,您应该在 php.ini 中更改以下变量:

; display_errors
; Default Value: On
; Development Value: On
; Production Value: Off

; display_startup_errors
; Default Value: On
; Development Value: On
; Production Value: Off

; error_reporting
; Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT 
; Production Value: E_ALL & ~E_DEPRECATED

; html_errors 
; Default Value: On 
; Development Value: On 
; Production value: Off

; log_errors
; Default Value: On 
; Development Value: On 
; Production Value: On

搜索它们,因为它们已经定义并输入您想要的值。然后重新启动您的 apache2 服务器,一切都会正常工作。祝你好运!

PHP errors NOT being displayed in the browser [Ubuntu 10.10]

还要检查是否安装了 PHP 试试

$ which php

【讨论】:

    猜你喜欢
    • 2020-03-04
    • 1970-01-01
    • 2011-04-17
    • 2022-08-04
    • 1970-01-01
    • 1970-01-01
    • 2019-04-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多