What are the errors in the following PHP code? Hint is there a missing function
ID: 3757937 • Letter: W
Question
What are the errors in the following PHP code? Hint is there a missing function call?
$string1 = “ A BIG STRING “;
$string1 = trim($string1);
$strLen = $string1;
echo "Sting length after TRIM: " . $strLen . "</br>";
echo "String after TRIM: " . $string1 . "</br>";
What are the errors in the following PHP code? Hint: Is the array formatted correctly?
$cars = array('v' =>, 'f' =>, 't' => 'Tesla');
print_r ( $cars );
What are the errors in the following PHP code?
HINT: The money function requires another function call before you can use it. Is it there?
$priceAmount = 1234.56;
$priceOut1 = money_format( "%i", $priceAmount);
echo "Price with " . '"%i"' . " " . $priceOut1 . "</br>";
What are the errors in the following PHP code?
Hint the date function requires anther function call before you can use it. Is it there?
// Prints the day
echo date("l") . "<br>";
// Prints something like: Monday 8th of August 2005 03:12:46 PM
echo date('l jS of F Y h:i:s A') . "<br>";
What are the errors in the following PHP code? Hint strlen does what? Is it for arrays?
$cars = array('Volvo', 'Ford', 'Tesla', 'Honda', 'BMW', 'Volkswagen');
$sizeOfArray = strlen($cars);
echo $sizeofArray;
$string1 = “ A BIG STRING “;
$string1 = trim($string1);
$strLen = $string1;
echo "Sting length after TRIM: " . $strLen . "</br>";
echo "String after TRIM: " . $string1 . "</br>";
Explanation / Answer
1.
$string1 = “ A BIG STRING “;
$string1 = trim($string1);
$strLen =strlen( $string1);
echo "Sting length after TRIM: " . $strLen . "</br>";
echo "String after TRIM: " . $string1 . "</br>";
2.
$cars = array('v' =>'Volvo', 'f' =>'Ferrari', 't' => 'Tesla');
print_r ( $cars );
3.
$priceAmount = 1234.56;
setlocale(LC_MONETARY, 'en_US');
$priceOut1 = money_format( "%i", $priceAmount);
echo "Price with " . '"%i"' . " " . $priceOut1 . "</br>";
4.
// Prints the day
echo date("l") . "<br>";
date_default_timezone_set('UTC');
// Prints something like: Monday 8th of August 2005 03:12:46 PM
echo date('l jS of F Y h:i:s A') . "<br>";
5.
$cars = array('Volvo', 'Ford', 'Tesla', 'Honda', 'BMW', 'Volkswagen');
$sizeOfArray = count($cars);
echo $sizeofArray;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.