Ny first PHP code

<div class="forloop">
	<?php
	for ( $x = 1; $x <= 4; $x ++ ) {
		echo "The number is: $x <br>";
	}
	?>
</div>

<div class="array">
	<?php
	$names = array( "Anders", "Kim", "Fredrik" );
	print_r( $names );
	?>
</div>

<div class="if">
	<?php
	$var1 = 20;
	$var2 = 40;

	if ( $var1 > $var2 ) {
		echo "$var1 er større enn $var2";
	} else {
		echo "$var1 er mindre enn $var2";
	}
	?>
</div>

<div class="function">
	<?php
	function first_function() {
		echo "Min første PHP funksjon";
	}

	first_function()
	?>
</div>

 

Leave a Reply

Your email address will not be published. Required fields are marked *