Assignment 2 Full Answers
Assignment 2 Full Answers
The array_flip() function in PHP exchanges the keys with their associated values in an array.
Syntax: imagecolorallocate(resource $image, int $red, int $green, int $blue): int
include: Includes a file but does not halt execution if the file is missing.
Syntax:
// Code to execute
An array in PHP is a data structure that stores multiple values in a single variable.
A variable function allows calling a function using a variable containing its name.
Example:
$func = 'strtolower';
Indexed arrays use numeric keys, whereas associative arrays use named keys.
PHP Code:
<?php
header('Content-Type: image/png');
imagepng($img);
imagedestroy($img);
?>
PHP Code:
<?php
function fibonacci($n) {
$num1 = 0; $num2 = 1;
$num1 = $num2;
$num2 = $temp;
fibonacci(10);
?>
A variable function allows calling a function using a variable containing its name.
Example:
$func = 'strlen';
Anonymous functions are functions without a name, used for inline execution.
Example:
PHP Code:
<?php
header('Content-Type: image/png');
imagepng($img);
imagedestroy($img);
?>
PHP Code:
<?php
header('Content-Type: image/png');
imagepng($img);
imagedestroy($img);
?>
PHP Code:
<?php
require('fpdf.php');
$pdf->AddPage();
?>