Home To Know Codes Start with PHP

Start with PHP

308
0
SHARE
Start with PHP

For starting with PHP, first you need know form where we start. It’s not like HTML, create a notepad file than change its extension & open in browser. In case of PHP you need to place your code file in Web Server directory with “.php” extension.

Your web server directory path will depends on what Web Server you install:

Wamp Server: C:\wamp64\www
Xamp Server: C:\xampp\htdocs

Create your first file with index.php

Write first code of your php

Example: 1
<?php
echo 'Hi einly';
?>

Output
Hi einly

Example: 2
<?php
print 'Hi einly';
?>

Output
Hi einly

Example: 3
<?php
print "Hi einly";
?>

Output
Hi einly

Commenting in php

Example: 4
<?php
//comment type 1
# comment type 2
/* comment
type 3*/
$x = 5+/* 15+ */5; //comment type 4 (in betwwen code line)
echo $x;
?>

Output
10

Case Sensitivity php

Example: 5
<?php
ECHO "Hi Netwax Lab!<br>";
echo "Hi Netwax Lab!<br>";
EcHo "Hi Netwax Lab!<br>";
?>

Output
Hi Netwax Lab!
Hi Netwax Lab!
Hi Netwax Lab!

Example: 6
<?php
$color = "red";
echo "My tie is " . $color . "<br>";
echo "My shirt is " . $COLOR . "<br>";
echo "My shoe is " . $coLOR . "<br>";
?>

Output

PHP Case Sensitivity Example Output
PHP Case Sensitivity Example Output

Leave a Reply