Skip to content

PHP Programming Basics Tutorial – Easy and quick | HOXFRAMEWORK

Posted in VIDEOS

Hello everyone and welcome back ! Today we are learning some PHP

Here is the code i used in the video (if you want a transcribed explaination of the code let me know on my instagram (hoxframework) ) :

<head></head>
<body>

	<h1>Hello world!</h1>
	
	<br/>
	
	<p> My name is: </p>
	
	<?php 
		$name = "John";
		echo($name);
		$lastname = "Smith";
		echo (" $lastname");
		#a comment 
		$yearBorn = 1998;
		//another comment
		
		$gpa = 3.5;
		$isAdmin = false;
		
		echo " was born in " . $yearBorn . " and has GPA: " . $gpa;
		
		
		echo "<br/><br/>is $name an admin?";
		if ($isAdmin == true){
			echo "He is.<br/>";
		} else {
			echo "He isnt.<br/>";
		}
		
		if($name == "John"){
			echo "Hey its John!!";
		} elseif ($name == "Mike") {
			echo "Hey its Mikey!";
		} else {
			echo "Hey you are unknown.";
		}
		
		// lets continue
		
		$day = date("N");
		
		if($day == 1) {
			$day_name = "Ponedjeljak-Monday";
		} elseif($day == 2){
			$day_name = "Utorak-Tuesday";
		}
		//and so on - but we have a better solution
		//if we want to go trough all days
		
		echo "<br><hr>";
		
		switch($day){
			case 3:
				$day_name = "Srijeda-Wednesday";
			break;
			case 4:
				$day_name = "Cetvrtak-Thursday";
			break;
			#And so on and so on until the last statement which is "default" similar to else
			default:
				$day_name = "Sunday-Nedjelja";
			break;
		}
			
		echo $day_name;
		
		$yourname = @$_GET["yourname"];
		if(isset($yourname)){
			echo "Good afternoon " . $yourname;
		}
		
		$yourlastname = isset($_GET["yourlastname"]) ? $_GET["yourlastname"] : "";
		
		//################
		echo "<br>";
		require("dataset.php");
		echo $eu25["Poland"];
		echo "<br>";
		//###
		echo "<hr>";
		foreach($eu25 as $nation => $city) {
			echo "$nation has a capital $city" . "<br/>";
		}
		echo "<hr>";
		
		##
		for($i=0; $i<10; $i++){
			echo "<b> Number $i </b> is my fav. </br>";
		}
		
		echo "<hr>";
		$k = 0;
		while($k < 10){
			echo "Second number:" . $k . "<br/>";
			$k++;
		}
		
	?>
	<br/>
	<p> That would be all </p>
</body>

And there we go thats all ! Thank you so much for visiting and have a nice day 😀