Chapter 3 files

This commit is contained in:
RobinNixon
2020-09-02 14:21:10 +01:00
committed by GitHub
parent 241b8a0f06
commit 44a047f3bf
18 changed files with 136 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
<?php
echo "Hello world";
?>
+4
View File
@@ -0,0 +1,4 @@
<?php
$number = 12345 * 67890;
echo substr($number, 3, 1);
?>
+5
View File
@@ -0,0 +1,5 @@
<?php
$pi = "3.1415927";
$radius = 5;
echo $pi * ($radius * $radius);
?>
+6
View File
@@ -0,0 +1,6 @@
<?php
function longdate($timestamp)
{
return date("l F jS Y", $timestamp);
}
?>
+7
View File
@@ -0,0 +1,7 @@
<?php
function longdate($timestamp)
{
$temp = date("l F jS Y", $timestamp);
return "The date is $temp";
}
?>
+9
View File
@@ -0,0 +1,9 @@
<?php
$temp = "The date is ";
echo longdate(time());
function longdate($timestamp)
{
return $temp . date("l F jS Y", $timestamp);
}
?>
+9
View File
@@ -0,0 +1,9 @@
<?php
$temp = "The date is ";
echo $temp . longdate(time());
function longdate($timestamp)
{
return date("l F jS Y", $timestamp);
}
?>
+9
View File
@@ -0,0 +1,9 @@
<?php
$temp = "The date is ";
echo longdate($temp, time());
function longdate($text, $timestamp)
{
return $text . date("l F jS Y", $timestamp);
}
?>
+13
View File
@@ -0,0 +1,13 @@
<?php
echo test();
echo "<br><br>";
echo test();
function test()
{
static $count = 0;
echo $count;
$count++;
}
?>
+5
View File
@@ -0,0 +1,5 @@
<?php
static $int = 0; // Allowed
static $int = 1+2; // Disallowed (will produce a Parse error)
static $int = sqrt(144); // Disallowed
?>
+6
View File
@@ -0,0 +1,6 @@
<?php
/* This is a section
of multi-line comments
which will not be
interpreted */
?>
+5
View File
@@ -0,0 +1,5 @@
<?php
$mycounter = 1;
$mystring = "Hello";
$myarray = array("One", "Two", "Three");
?>
+7
View File
@@ -0,0 +1,7 @@
<?php // test1.php
$username = "Fred Smith";
echo $username;
echo "<br>";
$current_user = $username;
echo $current_user;
?>
+7
View File
@@ -0,0 +1,7 @@
<?php
$oxo = array(array('x', ' ', 'o'),
array('o', 'o', 'x'),
array('x', 'o', ' '));
echo $oxo[1][2];
?>
+8
View File
@@ -0,0 +1,8 @@
<?php
$author = "Steve Ballmer";
echo "Developers, Developers, developers, developers, developers,
developers, developers, developers, developers!
- $author.";
?>
+10
View File
@@ -0,0 +1,10 @@
<?php
$author = "Bill Gates";
$text = "Measuring programming progress by lines of code is like
Measuring aircraft building progress by weight.
- $author.";
echo $text;
?>
+11
View File
@@ -0,0 +1,11 @@
<?php
$author = "Brian W. Kernighan";
echo <<<_END
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it.
- $author.
_END;
?>
+11
View File
@@ -0,0 +1,11 @@
<?php
$author = "Scott Adams";
$out = <<<_END
Normal people believe that if it aint broke, dont fix it.
Engineers believe that if it aint broke, it doesnt have enough
features yet.
- $author.
_END;
?>