1. Create a file named: DataTypes1.php in your text editor. 2. Using the followi
ID: 3550207 • Letter: 1
Question
1. Create a file named: DataTypes1.php in your text editor.
2. Using the following PHP code as an example, output 1) your name (using variables); 2) your major as a sentence string (again using a variable); 3) another sentence using in place substitution; 4) two to four lines of your favorite poem using assignment/concatonation; and 5) the poem using six of the string functions learned.
Examples (partial code):
<?php
echo "My name is " . $fname . " " . $lname, "<br />";
echo $sentence,"<br />";
echo "{$phrase} is my favorite movie.";
?><br />
<?php
$firstLine = "Two roads diverged in a wood, and I<br />";
$secondLine = "I took the one less traveled by<br />,";
$thirdLine = "And that has made all the difference.<br />";
$allLines =$firstLine;
$allLines .=$secondLine;
$allLines .=$thirdLine;
echo $allLines, "<br />";
echo strtolower($allLines), "<br />";
........etc. ?>
3. Please include HTML code to output in a browser.
Explanation / Answer
<!DOCTYPE html>
<html>
<head>
<title>Lab2</title>
</head>
<body>
<?php
$fname="last";
$lname='knight';
$major='computers science';
echo "My name is " . $fname . " " . $lname, "<br />";
$movie='Batman Begins';
echo "{$movie} is my favorite movie.";
?><br />
<?php
$firstLine = "Two roads diverged in a wood, and I<br />";
$secondLine = "I took the one less traveled by<br />,";
$thirdLine = "And that has made all the difference.<br />";
$allLines =$firstLine;
$allLines .=$secondLine;
$allLines .=$thirdLine;
echo $allLines, "<br />";
echo strtolower($allLines), "<br />";
echo strlen($allLines), "<br />";
echo strtolupper($allLines), "<br />";
?>
</body>
</html>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.