Post-2 (PHP) Start First PHP Page - NetwaxLab

Breaking

Facebook Popup

BANNER 728X90

Saturday, March 26, 2016

Post-2 (PHP) Start First PHP Page

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:
  1. Wamp Server: C:\wamp64\www
  2. Xamp Server: C:\xampp\htdocs
Create your first file with index.php

# Write first code of your php


  • Example: 1
<?php
echo 'Hi Netwax Lab';
?>

Output
Hi Netwax Lab
  • Example: 2
<?php
print 'Hi Netwax Lab';
?>

Output

Hi Netwax Lab
  • Example: 3
<?php
print "Hi Netwax Lab";
?>

Output

Hi Netwax Lab

# 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



----

No comments:

Post a Comment