DEVTOME.COM HOSTING COSTS HAVE BEGUN TO EXCEED 115$ MONTHLY. THE ADMINISTRATION IS NO LONGER ABLE TO HANDLE THE COST WITHOUT ASSISTANCE DUE TO THE RISING COST. THIS HAS BEEN OCCURRING FOR ALMOST A YEAR, BUT WE HAVE BEEN HANDLING IT FROM OUR OWN POCKETS. HOWEVER, WITH LITERALLY NO DONATIONS FOR THE PAST 2+ YEARS IT HAS DEPLETED THE BUDGET IN SHORT ORDER WITH THE INCREASE IN ACTIVITY ON THE SITE IN THE PAST 6 MONTHS. OUR CPU USAGE HAS BECOME TOO HIGH TO REMAIN ON A REASONABLE COSTING PLAN THAT WE COULD MAINTAIN. IF YOU WOULD LIKE TO SUPPORT THE DEVTOME PROJECT AND KEEP THE SITE UP/ALIVE PLEASE DONATE (EVEN IF ITS A SATOSHI) TO OUR DEVCOIN 1M4PCuMXvpWX6LHPkBEf3LJ2z1boZv4EQa OR OUR BTC WALLET 16eqEcqfw4zHUh2znvMcmRzGVwCn7CJLxR TO ALLOW US TO AFFORD THE HOSTING.

THE DEVCOIN AND DEVTOME PROJECTS ARE BOTH VERY IMPORTANT TO THE COMMUNITY. PLEASE CONTRIBUTE TO ITS FURTHER SUCCESS FOR ANOTHER 5 OR MORE YEARS!

PHP Examples

Note: I understand the indentation is very off, but try to bear with it as text processors have horrible indentation styling than environments.

Hello World

<!DOCTYPE html>
<html>
<head>
	<link type="text/css" rel="stylesheet" href="style.css"/>
		<title>Hello World</title>
	</head>
	<body>
<p>Hello World!</p>
	</body>
</html>

Hello World Alternative

<!DOCTYPE html>
<html>
	<head>
<link type="text/css" rel="stylesheet" href="style.css"/>
<title>Hello World Alternative</title>
	</head>
	<body>
<p>
<?php
echo "Hello World!" ;
?>
</p>
	</body>
</html>

Math

Addition:

<!DOCTYPE html>
<html>
	<head>
<link type="text/css" rel="stylesheet" href="style.css"/>
<title>Addition</title>
	</head>
	<body>
<p>
<?php
echo 2 + 2;
?>
</p>
	</body>
</html>

Subtraction:

<!DOCTYPE html>
<html>
	<head>
<link type="text/css" rel="stylesheet" href="style.css"/>
<title>Subtraction</title>
	</head>
	<body>
<p>
<?php
echo 2 - 2;
?>
</p>
	</body>
</html>

Multiplication:

<!DOCTYPE html>
<html>
	<head>
<link type="text/css" rel="stylesheet" href="style.css"/>
<title>Multiplication</title>
	</head>
	<body>
<p>
<?php
echo 2 * 2;
?>
</p>
	</body>
</html>

Division:

<!DOCTYPE html>
<html>
	<head>
<link type="text/css" rel="stylesheet" href="style.css"/>
<title>Division</title>
	</head>
	<body>
<p>
<?php
echo 2 / 2;
?>
</p>
	</body>
</html>

Modulo:

<!DOCTYPE html>
<html>
	<head>
<link type="text/css" rel="stylesheet" href="style.css"/>
<title>Modulo</title>
	</head>
	<body>
<p>
<?php
echo 2 % 2;
?>
</p>
	</body>
</html>

Variables

<!DOCTYPE html>
<html>
	<head>
<link type="text/css" rel="stylesheet" href="style.css"/>
<title>Variable</title>
	</head>
	<body>
<p>
<?php
$StringVariable = "Hello World!";
$IntVariable = 0;
echo $StringVariable;
echo $IntVariable;
?>
</p>
	</body>
</html>

Variable Math

Addition:

<!DOCTYPE html>
<html>
	<head>
<link type="text/css" rel="stylesheet" href="style.css"/>
<title>Variable Math</title>
	</head>
	<body>
<p>
<?php
$myFirstVariable = 2 + 2;
echo $myFirstVariable;
?>
</p>
	</body>
</html>

Subtraction:

<!DOCTYPE html>
<html>
	<head>
<link type="text/css" rel="stylesheet" href="style.css"/>
<title>Variable Math</title>
	</head>
	<body>
<p>
<?php
$myFirstVariable = 2 - 2;
echo $myFirstVariable;
?>
</p>
	</body>
</html>

Multiplication:

<!DOCTYPE html>
<html>
	<head>
<link type="text/css" rel="stylesheet" href="style.css"/>
<title>Variable Math</title>
	</head>
	<body>
<p>
<?php
$myFirstVariable = 2 * 2;
echo $myFirstVariable;
?>
</p>
	</body>
</html>

Division:

<!DOCTYPE html>
<html>
	<head>
<link type="text/css" rel="stylesheet" href="style.css"/>
<title>Variable Math</title>
	</head>
	<body>
<p>
<?php
$myFirstVariable = 2 / 2;
echo $myFirstVariable;
?>
</p>
	</body>
</html>

Modulo:

<!DOCTYPE html>
<html>
	<head>
<link type="text/css" rel="stylesheet" href="style.css"/>
<title>Variable Math</title>
	</head>
	<body>
<p>
<?php
$myFirstVariable = 2 % 2;
echo $myFirstVariable;
?>
</p>
	</body>
</html>

Comment

<!DOCTYPE html>
<html>
	<head>
	<link type="text/css" rel="stylesheet" href="style.css"/>
	<title>Variable Math</title>
	</head>
	<body>
	<p>
		<?php
		// This is a comment, the language will always ignore anything after this
		/* This is a multiline comment,
		anything after the slash and multiplication sign will be ignored,
		until a multiplication sign and a slash is typed */
		?>
	</p>
</body>
</html>

If/Else Age Verification

<!DOCTYPE html>
<html>
	<head>
	<link type="text/css" rel="stylesheet" href="style.css"/>
	<title>Variable Math</title>
	</head>
	<body>
	<p>
		<?php
      		$age = 17;
       		if ($age >= 18) {
			echo "You may enter!";
		} else {
			echo "Not there yet buddy!";
       		}
		?>
	</p>
</body>
</html>

Sales Discount

<!DOCTYPE html>
<html>
	<head>
		<link type="text/css" rel="stylesheet" href="style.css"/>
		<title>Variable Math</title>
	</head>
	<body>
		<p>
			<?php
	$items = 6;
	if ($items > 5) {
		echo "You get a 10% discount!";
	} elseif ($items == 1) {
		echo "Sorry, no discount!";
	} elseif ($items <= 0) {
		echo "Select an item please!";
	} else {
		echo "You get a 5% discount!";
	}
?>
<p>
</body>
</html>

Programming


QR Code
QR Code php_examples (generated for current page)
 

Advertise with Anonymous Ads