“Learn PHP the Hard way”

Welcome to the DevNotch.com, Today I teach you the “Learn PHP the Hard way“. It’s a Fact that we always provide the valuable Information which is important for your knowledge OR debate for the world.

Today, We’re provided a PHP Tutorials which is basically more important for programmers & Developers. Unfortunately, As we know that the PHP is an open source language which is the big part of web development.

Index/Phrase :

Learn PHP the Hard way Article, I teach you about some important topics which are important for your work OR Knowledge.

  1. Introduction of PHP
  2. PHP Servers
  3. PHP HelloWorld
  4. PHP Variables
  5. PHP Concatenation
  6. PHP SuperGlobal Variable
  7. PHP Constants
  8. PHP Operators
  9. PHP Decision Making
  10. PHP Loops
  11. PHP Switch Tutorial
  12. PHP Arrays
  13. PHP Filter tutorial
  14. PHP Get / POST
  15. PHP I/O Files Tutorials
  16. PHP Functions
  17. PHP Cookies
  18. PHP SESSIONS
  19. PHP Object Oriented Programming (OOP) tutorials
  20. PHP File Uploading
  21. PHP Email SEND Tutorial
  22. PHP Error Handling
  23. PHP Regular Expression
  24. PHP / MYSQL Tutorials
  25. PHP XML Tutorials
  26. PHP Ajax Tutorials
  27. PHP RSS Feed Tutorial
  28. PHP Built-in Function
  29. Core PHP vs Frameworks
  30. PHP Frameworks

Introduction of PHP – Learn PHP the Hard way :

Learn PHP the Hard way – It’s a well-established fact that the PHP is powerful Language in the Web development Service. PHP stand for PHP Hypertext Preprocessor. PHP Connect with the more language like C++, Android, Java & etc.

PHP Server :

Learn PHP the Hard way – It’s a fact that the PHP run in the only server because PHP is a Server Side Scripting Language. Few people would deny that they have always get the error in the script. I think we can all accept about Xampp Server. This is a good server for Practice of PHP If you want to don’t waste a time then you can download the USB Web server.

  1. XAMPP Download
  2. USB Web Server Download

PHP HelloWorld :

Learn PHP the Hard way – If you have the interest in this language So I promise you that you have made an Expert Developer who works on PHP easily. I wonder if you tell me that you read this full PHP Course article then I’m sure that you become a good PHP Developer who’s work on any project of website development & etc.

First I tell you that the PHP Start with his own tag “<?” which is name is Less Than & Question mark sign.

PHP End with his own tag like “?>” which name is Question mark sign & Greater Than

The HelloWorld tutorials are shown below :

<?PHP
echo “DevNotch“;
print “DevNotch”;
?>

The twice’s similar to both. If you want to show any text OR etc then you can use this command.

PHP Variables :

PHP Variable is a very simple part of PHP which is consist of the Every Language like (Javascript , JAVA , C# , ETC). The Simple PHP Variable tutorial is that just you write the dollar sign like ($) and type the name of your variable with his. Unfortunately, Your variable has developed just you place your value which you want to put in your variable. Understand that you’ve not able to provide any data type like other languages.

Here the Example that how to can make a variable in PHP :

<?PHP
$Helloworld = “DevNotch“;
echo $Helloworld;
?>

PHP Concatenation :

PHP Concatenation is very simple & important part of PHP language. It’s used when you connect you Variables to one side. You can see the Example in below :

<?PHP
$Hello = “Dev”;
$World = “Notch”;
echo $Hello.$World;
?>

PHP SuperGlobal Variable :

The PHP SuperGlobal means a Special Variable which is predefined in PHP Language. There are display the SuperGlobal Variables which is mention below :

  • $GLOBALS
  • $_SERVER
  • $_REQUEST
  • $_POST
  • $_GET

$GLOBAL Tutorial in PHP :

The $GLOBAL is a Powerful Variable which is taken the value in a variable.

Here the Example of $GLOBALS :

<?PHP
$Work = “Trick”;
function dev(){
$GLOBALS[‘Dev’] = $GLOBALS[‘Work’];
}
dev();
echo $Dev;
?>

$_SERVER Tutorial in PHP :

Learn PHP the Hard way – There are following server variables which is constant in PHP many peoples use this Variable for hacking but it’s a bad way to work on PHP language. Therefore, I couldn’t teach you that how to hack with this Variables.

<?PHP
echo $_SERVER[‘PHP_SELF’];
?>

Here the list which is important for your work in PHP.

List Of Server Value :

  1. PHP_SELF
  2. SERVER_NAME
  3. HTTP_HOST
  4. HTTP_REFERER
  5. HTTP_USER_AGENT
  6. SCRIPT_NAME
  7. SCRIPT_URI
  8. PATH_TRANSLATED
  9. SERVER_SIGNATURE
  10. SERVER_ADMIN
  11. SERVER_PORT
  12. SCRIPT_FILENAME
  13. REMOTE_PORT
  14. HTTP_HOST
  15. HTTPS
  16. REMOTE_ADDR
  17. HTTP_ACCEPT
  18. QUERY_STRING
  19. REQUEST_TIME
  20. SERVER_PROTOCOL
  21. SERVER_SOFTWARE
  22. SERVER_NAME

$_REQUEST / $_GET / $_POST :

Learn PHP the Hard way – Here the some important variables which is important for your Form. When you make a form in HTML then you can his value in PHP. For the value of HTML form get via these important Variables This Work in POST. Here the Example below :

<form method=”POST” action=”<?php echo $_SERVER[‘PHP_SELF’];?>”>
Name: <input type=”text” name=”Write”/>
<input type=”submit value=”Submit”/>
</form>

<?php
echo $_REQUEST[‘Write’];
echo $_REQUEST[‘POST’];
?>

If you put the GET Method in for then you have to put the $_REQUEST[‘GET’]; in PHP which work on your domain / URL like this (devnotch.com/test.php?Write=123).

PHP Constants :

The PHP Constant is the main part of PHP Language where you can a variable with another point of view. Define is a constant variable who’s got the 2 OR 3 parameters. The first Parameter is the Name OF Variable & 2nd Parameter is a value OF Variable. After all the 3rd variable is used for the Case-Sensitivity of Variable. You can use this variable everywhere in your document. Here the Example is mention below :

<?PHP
define(“Pre”, “DevNotch.com!”, true);
echo Pre;
?>

PHP Operator :

It’s a Fact that the PHP Operators has consisted only 5 Operators.

  1. Arithmetic Operators
  2. Comparison Operators
  3. Logical Operators
  4. Assignment Operators
  5. Conditional Operators

PHP Arithmetic Operator tutorial :

  1. Addition (+)
  2. Subtraction (-)
  3. Multiplication (*)
  4. Divide (/)
  5. Modulus (%)
  6. Increment Operator (++)
  7. Decrement Operator (–)

PHP Comparison Operator tutorial :

  1. Double Equal to (==)
  2. Not Equal to (!=)
  3. Less than (<)
  4. Greater than (>)
  5. Less Than Equal to (<=)
  6. Greater Than Equal to (>=)

Conditional Operator :

If value true ? then X : Otherwise Y

Logical Operators :

  1. and
  2. &&
  3. OR
  4. !
  5. ||

Assignment Operators :

  1. =
  2. +=
  3. -=
  4. *=
  5. %=
  6. /=

PHP IF / Else Condition :

When you make a condition in your document so it’s important for you that you use an If / Else Condition. Here the Example are shown below :

<?php
$t = date(“H”);
if ($t < “20”) {
echo “Good Day for you!”;
}else{
echo “Enjoy friends!”
}
?>

PHP Loops tutorials :

In PHP 4 types of loop which is mention below with Example :

<?php
for ($a = 0; $a <= 10; $a++) {
echo “The number is: $a <br>”;
}
$b = 1;
while($x <= 5) {
echo “The number is: $b <br>”;
$b++;
}
$c = 1;
do {
echo “The number is: $c <br>”;
$c++;
} while ($c <= 5);
$websites = array(“hamariweb”, “DevNotch”, “Naginamobile”, “Jobguarantee”);
foreach ($websites as $value) {
echo “$value <br>”;
}
?>

PHP Switch Tutorial :

In this step, we’re provided us a simple Switch statement where you check your command on Switch Condition.

<?php
$favcolor = “dev”;
switch ($favcolor) {
case “w3”:
echo “Your fav website is w3School!”;
break;
case “dev”:
echo “Your fav website is DevNotch!”;
break;
default:
echo “Empty website!”;
}
?>

PHP Arrays :

The PHP Arrays is a main part of PHP Language which is the good symbol of any Language. In the array, You have store the more values in 1 variable with the help of array. Here the Example are shown below :

<?php
$quote = array(“Come “, “on “, “DevNotch!”);
echo “I like to ” . $quote[0] . $quote[1] . $quote[2] . “.”;
?>

Get the values of PHP in Infinite Number :

<?php
$Cars = array(“Honda”, “BMW”, “Corolla”);
$length = count($Cars);
for($a = 0; $a < $length; $a++) {
echo $Cars[$a];
echo “<br>”;
}
?>

PHP Associated array which is usually used in Frameworks OR Big projects.

<?php
$ages = array(“Mike”=>”35”, “John”=>”37”, “Doe”=>”43”);
echo “John is ” . $ages[‘John’] . ” years old.”;
?>

PHP Filter Tutorial :

The list of filters function we’re shown in below :

filter_has_var() Checks if a variable of a specified input type exist
filter_id() Returns the filter ID of a specified filter name
filter_input() Gets an external variable (e.g. from form input) and optionally filters it
filter_input_array() Gets external variables (e.g. from form input) and optionally filters them
filter_list() Returns a list of all supported filters
filter_var_array() Gets multiple variables and filter them
filter_var() Filters a variable with a specified filter

PHP Object Oriented Programming (OOP) :

The PHP object oriented programming consist only 13 components which name is mention below :

  1. Class
  2. Object
  3. Member Variable
  4. Member Function
  5. Inheritance
  6. Parent Class
  7. Child Class
  8. Polymorphism
  9. Overloading
  10. Data Abstraction
  11. Encapsulation
  12. Constructor
  13. Destructor

There are the few important topics of OOP which is included in PHP Language. Make sure that you have to able to read full OOP Concept which is important for Interview & More Projects.

Example of Class :

Learn PHP the Hard way – The Class like a template where you can make more functions & Other data which is included in your template.

<?PHP
Class className{
// Type your command
}
?>

Example of Object :

Learn PHP the Hard way – The Object is used for calling a class where your class perform in your document. View the small Example of Object.

<?PHP
Class className{
function devNotch(){
echo “Welcome to DevNotch!”;
}
}
$dev = new className;
$dev->devNotch();
?>

Calling Member Variable & Function Example :

<?PHP
Class className{
static $member = 123;
function devNotch(){
echo “Welcome to DevNotch!”;
}
}
// Call a Variable from inside the Class
echo className::$member;
// Get a Class from Object
$dev = new className;
// Call a Function from inside the Class
$dev->devNotch();
?>

PHP Inheritance Example :

<?PHP
Class first{
// Command
}
Class second extends first{
// Command
}
?>

PHP Constructor :

Learn PHP the Hard way – The PHP Constructor is same as the other languages where the constructor call to first time of any function OR data.

<?PHP
Class className{
function __construct( ) {
echo “Welcome to DevNotch.com!”;
}
}
$dev = new className;
?>

PHP Overriding Function :

Learn PHP the Hard way – The PHP Overriding function means It’s a fact that when we inherit the class in child class but the functions name are similar of both. Here the Example below :

<?PHP
Class first{
function DevNotch( ) {
echo “Welcome to DevNotch.com!”;
}
}
Class second extends first{
function DevNotch( ) {
echo “Go away from DevNotch.com!”;
}
}
$dev = new first;
$dev->DevNotch();
$Notch = new second;
$Notch->DevNotch();
?>

PHP Interface Example :

This is a interface it’s still work in OOP which is included in more languages.

<?PHP
interface a
{
public function get();
}
class UserData implements a
{
public function get(){
echo “Welcome to DevNotch.com! Interface”;
}
}
$a = new UserData;
$a->get();
?>

PHP abstract Example :

abstract is also a part of OOP which is use in this script.

<?php
interface water
{
public function makeItWet();
}
abstract class weather implements water
{
private $cloudy;
public function makeItWet(){}
abstract public function start();
}
class rain extends weather  {
private $cloudy;
public function start() {
return “Working Process …. “;
}
public function makeItWet() {
return ‘Complete Process’;
}
}
$a = new rain();
echo $a->start();
echo $a->makeItWet();
?>

PHP Get / POST Tutorial :

<html>
<body>
<form action=”welcome.php” method=”POST”>
Name: <input type=”text” name=”name”><br>
<input type=”submit”>
</form>

<form action=”welcome.php” method=”GET”>
E-mail: <input type=”text” name=”email”>
<input type=”submit”>
</form>
</body>
</html>

2nd file

Welcome <?php echo $_POST[“name”]; ?><br>
Your email address is: <?php echo $_GET[“email”]; ?>

PHP I/O Files Tutorials :

<?php
$myfile = fopen(“devnotch.txt”, “r”) or die(“Could Not Open at the Moment!”);
echo fread($myfile,filesize(“devnotch.txt”));
fclose($myfile);
?>

PHP File (End of file) :

<?php
$myfile = fopen(“devnotch.txt”, “r”) or die(“Empty !”);
// Output one line until end-of-file
while(!feof($myfile)) {
echo fgets($myfile) . “<br>”;
}
fclose($myfile);
?>

PHP File Create Tutorials :

$myfile = fopen(“devnotch.txt”, “w”);
File Write via these command.
<?php
$myfile = fopen(“devnotch.txt”, “w”) or die(“Null !”);
$txt = “Dev Notch\n”;
fwrite($myfile, $txt);
$txt = “Jane Doe\n”;
fwrite($myfile, $txt);
fclose($myfile);
?>

Delete File in PHP Tutorials :

If you use this script then you can easily delete any file which is upload on your server OR PC.

<?php
$fh = fopen(‘devnotch.html’, ‘a’);
fwrite($fh, ‘<h1>Hello world!</h1>’);
fclose($fh);
unlink(‘devnotch.html’);
?>

PHP Functions :

It’s very simple & important tutorial of PHP because Function is using in all the languages.

<?php
function DevNotch(){
echo “Simple Function”;
}
DevNotch();
?>

PHP Cookies :

PHP Cookies work in Your browser where you can store your varible value OR array value in Cookie.

<?php
//set COokie
setcookie(“user”, “JDoe”);
//get COokie
echo $_COOKIE[“user”];
?>

PHP SESSION :

PHP Session is a simple tutorial of PHP which work to store data in browser.

<?php
session_start();
// Set session variables
$_SESSION[“web”] = “devnotch”;
echo $_SESSION[“web”];
print_r($_SESSION);
// remove all session variables
session_unset();
// destroy the session
session_destroy();
?>

PHP File Uploading Tutorial :

This is very simple script which is using for upload any image OR text file where you want to place him.

<form action=”upload.php” method=”post” enctype=”multipart/form-data”>
Select image to upload:
<input type=”file” name=”fileToUpload” id=”fileToUpload”>
<input type=”submit” value=”Upload Image” name=”submit”>
</form>

Make a 2nd file :

<?php
$target_dir = “uploads/”;
$target_file = $target_dir . basename($_FILES[“fileToUpload”][“name”]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image
if(isset($_POST[“submit”])) {
$check = getimagesize($_FILES[“fileToUpload”][“tmp_name”]);
if($check !== false) {
echo “File is an image – ” . $check[“mime”] . “.”;
$uploadOk = 1;
} else {
echo “File is not an image.”;
$uploadOk = 0;
}
}
?>

PHP Email Send Tutorial :

This is a simple Message Sending tutorials in PHP.If you place this script on your website server then it’s common knowledge that  this tutorial work to every SMTP because in the hosting server every server are placed. which I write in the below :

<?php
mail(“devnotchs@gmail.com“,”DevNotch like a Subject”,$msg);
?>

View More Articles via DevNotch :

  1. CSS3
  2. Android Tutorials
  3. Off Page SEO
  4. On Page SEO
  5. Guest Blogging Sites
  6. CakePHP

Leave a Reply