-1

I have the current code and it only works if I comment out the function. Help? It doesn't show the title tag or anything. I'm thinking it's some syntax I'm missing, but have not seen it as of yet.

<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>
OysterMaker
  • 239
  • 2
  • 10
  • 24

1 Answers1

1

To make it work you should change the following variables in your 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

Search for them as they are already defined and put your desired value. Then restart your apache2 server and everything will work fine. Good luck!

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

Also check if PHP is installed or not Try

$ which php
Community
  • 1
  • 1
Harshit
  • 4,929
  • 7
  • 36
  • 81