You are on page 1of 6

PHP TUTORIALS

TOOLS CONFIGURATION
Install Xampp
Install Visual Studio Code
Install PHP Storm
Install PHPO Inteliphense extension in Visual Studio Code

To begin with,

 Open XAMPP Control Panel


 Start Apache and MySQL
(If MySQL won’t start, turn it off and go to Local disk 6 and
look for XAMPP folder. Look for msql folder and locate the bin
folder. Open my.ini and look for “port =336”. Change the value to
3307, like these:
# password = your_password
port = 3307
socket = "C:/xampp/mysql/mysql.sock"

and
# The MySQL server
[mysqld]
port= 3307

 To check the connection, type localhost to your browser and


you must see this:

 Type localhost/phpmyadmin/ to your browser


(If the browser displays ACCESS DENIED, turn off MySQL from
the XAMPP control panel. Click Config and select my.ini.
Insert the line “skip-grant-tables” into this line, like
this, and save Notepad:
# The MySQL server
[mysqld]
skip-grant-tables
port= 3307
Refresh the browser if it will still displays the ACESS
DENIED. If still denied, stop mysql and apache from the
XAMPP control panel and click Config button at the top most
right of the panel. Click Service and Port Setting, and open
MySQL tab. Change main port value to 3307. Go to drive C and
look for the XAMPP folder. Open myPhp admin folder. Look for
file called config.inc.php and open it using Notepad++. Look
for /* Bind to the localhost ipv4 address and tcp */ and
change the host value to localhost:3307 and then Restart the
browser
/* Bind to the localhost ipv4 address and tcp */
$cfg['Servers'][$i]['host'] = 'localhost:3307';
$cfg['Servers'][$i]['connect_type'] = 'tcp';

 Go to CMD and type php -v.


(If “php is not recognized”, go to C drive and open xampp
folder. Look for php folder and locate php.exe file. Copy
the path and go to Computer, right click and go to
Properties.

Select Advance System Settings, then to Environment


Variables. Select Path (in the system variables), then edit.
Add the php.exe path to the ending, like this:
C:\Program Files\Common Files\Oracle\Java\javapath;%SystemRoot
%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT
%\System32\WindowsPowerShell\v1.0\;C:\Program
Files\Java\jdk1.8.0_281\bin;C:\Program Files\dotnet\;C:\Program
Files\GtkSharp\2.12\bin;C:\Program Files\Microsoft VS Code\bin;C:\Program
Files\MySQL\MySQL Utilities 1.6\;C:\xampp\php
Click OK, then restart CMD and type php -v. The command
prompt should display the following lines:

 Re-run the XAMPP Control Panel from the xampp folder in


Drive C. Look for xampp-control and run it as Administrator.
 Go to Config at the left side of the Panel and click it.
Mark Apache and MySQL with Check and Save.
 Open the browser and go to github.com/thecodeholic/php-
crash-course-2020
 Download the code as ZIP
 Copy the ZIP file to the folder to htdocs (inside the xampp
installation folder in drive C)
 Extract the ZIP file in the htdocs and rename it by removing
the word “master”, so it will become “php-crash-course-2020”
 Open the folder, and then the second folder inside. Cut all
the files inside the 2 folder and paste it inside the first
folder. So now that the 2nd folder is already empty, we can
now delete this empty folder.
 Now, if we type the folder name next to the localhost like
http://localhost/php-crash-course-2020/ in the browser, we
can then have this:
Hello World

In this lesson we are going to run a Hello World program in PHP


using the tool called PHPStorm. If you have PHPStorm in your
computer, run this program and select Open Project. Look for
php_crash_course folder in htdocx of the xampp folder in Drive C.
Once opened in PHPStorm, look for the file name
00_sytax.html.Once opened, you will see a set of html codes where
the message Hello World is included.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-
scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
Hello World
<!--Echo HTML tags-->
</body>
</html>

Rename the syntax file with .php extension, making it as


00_sytax.php. Now that the file was already converted as a php
file, to write Hello World we will use the following syntax:

<?php
echo "Hello Philippines!";
echo '<br>';
echo "Hello World!";
?>

The ‘<br>’ tag is an html tag that separate the statements into
new lines. Using those codes, we will have the following output:

Hello Philippines!
Hello World!

Buttons
<?php
echo "Hello Philippines!";
echo '<br>';
echo "Hello World! ";
echo '<button> Click Me </button>';
?>
Variables
PHP Variables:
 String
 Integer
 Float / double
 Boolean
 Null
 Array
 Object
 Resource
<?php
$name = 'Jerome Macarilao';
$isMale = true;
$Age = 37;
$Occupation = 'Customer Service Representative';
$Salary = null;

// outputs

echo $name;
echo '<br>';
echo $isMale;
echo '<br>';
echo $Occupation;

?>

Jerome Macarilao
1
Customer Service Representative
Gettype Command
This command displays what kind of type is being used in a
variable. For example:
<?php
$name = 'Jerome Macarilao';
$isMale = true;
$Age = 37;
$Occupation = 'Customer Service Representative';
$Salary = null;

// outputs

echo $name;
echo '<br>';
echo $isMale;
echo '<br>';
echo $Occupation;
echo '<br>';

echo gettype ($name);


echo '<br>';
echo gettype ($Age);
echo '<br>';
echo gettype ($isMale);

?>
Result:

Jerome Macarilao
1
Customer Service Representative
string
integer
boolean

Var_dump Command
Var_dump command is used to display the list of several variable
and their type in a single line. For example:
<?php
$name = 'Jerome Macarilao';
$isMale = true;
$Age = 37;
$Occupation = 'Customer Service Representative';
$Salary = null;

// outputs
var_dump ($name, $Occupation, $Age);
?>

Result:
string(16) "Jerome Macarilao" string(31) "Customer Service
Representative" int(37)
is_ Command
The is_ command is used to confirm or validate what type is being
used in a variable. For example:
33:09
https://www.youtube.com/watch?v=yXzWfZ4N4xU

You might also like