Coding in PHP

Install MAMP

  • install MAMP
  • launch MAMP
  • Preferences
    • General -> Start Servers
    • Ports -> 8888, 8889
    • PHP -> 7.4.2
    • WebServer ->Apache
      • note the Document root
        this is where we are going to create out PHP project
    • MySql -> 5.7.26
    • Cloud -> ignore
  • Start Servers

Create the Play Database

  • From the MAMP Setup screen Open WebStart
    • Tools -> PHPMYADMIN
    • Databases -> Create -> Play
    • Create Table -> people, columns: 4
      • name -> Varchar, 20
      • age -> int
      • height -> float
      • weight -> float
    • Preview SQL
CREATE TABLE `Play`.`people` ( 
    `name` VARCHAR(20) NOT NULL , 
    `age` INT NOT NULL , 
    `height` FLOAT NOT NULL , 
    `weight` FLOAT NOT NULL ) 
ENGINE = InnoDB;
  • insert
    • Jon Doe, 21, 1.85, 196
    • Jane Doe, 18, 1.72, 126
INSERT INTO `people` (`name`, `age`, `height`, `weight`) 
VALUES ('Jon Doe', '21', '1.85', '196'), ('Jane Doe', '18', '1.72', '126');
  • search
  • go

Create the PHP Project Folder

Create folder PHP in Application / MAMP / htdocs

This is our root folder

in PHP create index.php

<!DOCTYPE html>
<html>
<body>

<?php
echo "Hello World!";
?>

</body>
</html>

Review your Code

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.