PHP and HTML interact?

php-training-in-gurgaon
PHP is an HTML-embedded server-side scripting language. The goal of the language is to allow web developers to write dynamically generated pages quickly. NTC Hosting offers its clients high quality PHP and HTML hosting services. Our servers are configured so as to ensure maximum performance for both your HTML and PHP-based applications and the non-interruptible functioning of your websites. Example <?php $Fname = $_POST["Fname"]; $Lname = $_POST["Lname"]; ?> <html> <head> <title>Personal INFO</title> </head> <body> <form method="post" action="<?php echo $PHP_SELF;?>"> First Name:<input type="text" size="12" maxlength="12" name="Fname"><br /> Last Name:<input type="text" size="12" maxlength="36" name="Lname"><br /></form> <? echo "Hello, ".$Fname." ".$Lname.".<br />"; ?>
Read More

Multiple inheritance in PHP?

php-training-in-gurgaon
Inheritance is a well-established programming principle, and PHP makes use of this principle in its object model. This principle will affect the way many classes and objects relate to one another. For example, when you extend a class, the subclass inherits all of the public and protected methods from the parent class. Unless a class overrides those methods, they will retain their original functionality. This is useful for defining and abstracting functionality, and permits the implementation of additional functionality in similar objects without the need to reimplement all of the shared functionality. Example <?php class Foo { public function printItem($string) { echo 'Foo: ' . $string . PHP_EOL; } public function printPHP() { echo 'PHP is great.' . PHP_EOL; } } class Bar extends Foo { public function printItem($string) { echo 'Bar: ' . $string . PHP_EOL; } } $foo = new Foo(); $bar = new Bar(); $foo->printItem('baz'); // Output: 'Foo: baz' $foo->printPHP();       // Output: 'PHP is great' $bar->printItem('baz'); // Output: 'Bar: baz' $bar->printPHP();       // Output: 'PHP is great' ?>
Read More

PHP – Strings Functions

php-training-in-gurgaon
String functions are the most important functions frequently used in PHP. String is the sequence of characters, like "Let’s learn String functions”. There is no installation required to use string function. Example <?php $name = "Hirdesh Bhardwaj"; print($name); ?> String Concatenation Operator To concatenate two string variables together, we use the dot (.) operator − <?php $txt1="Hello Readers"; $txt2="8756"; echo $txt1 . " " . $txt2; ?> Using the strlen() function The strlen() function is used to get the length of a string. <?php $txt=”Webs Jyoti”; echo strlen($txt); ?> This will produce the following result – 10 (including space) Using the strpos() function The strpos() function is used to search for a text or character within a string. If the value is found then this will return the position of…
Read More

OOPs Concepts – PHP

php-training-in-gurgaon
OOP is intimidating to a lot of developers because it introduces new syntax and, at a glance, appears to be far more complex than simple procedural, or inline, code. However, upon closer inspection, OOP is actually a very straightforward and ultimately simpler approach to programming. Before we go in details, let’s define important terms related to Object Oriented Programming. Class− Simply Class is a collection of member variables and its functions. Object−You define a class once and then make many objects that belong to it. Objects have state behavior and identity. Member functions and Variables− these are the functions and variables defined inside a class and are used to access object data. Inheritance– Simply creating a new class from the existing class. When a class is defined by inheriting existing…
Read More

Working with Images – PHP

php-training-in-gurgaon
We need to create an HTML form that allows you to choose the file to be uploaded. Note: please make sure you have form method type is post and enctype=”mutipart/form-data” to to handle file uploading process successfully. HTML Code <form enctype="multipart/form-data" action="process.php" method="POST"> Choose File : <input name="myfile" type="file" /> <input type="submit" value="Upload" /> </form> Now create a PHP file process.php for handling file information <?php // get the uploaded file name $filename= $_FILES['myfile'][‘name’]; // get the file type $filetype= $_FILES['myfile'][‘type’]; // get the file size (in bytes) $filesize= $_FILES['myfile'][‘size’]; // You may put your validations here i.e restrict file size if($filesize>=1000000) { echo “ File is too Large, Maximum file size should be 1 MB”; exit; } // Validation to check if uploaded file is an Image if($filetype !=”image/jpeg”…
Read More

Sending email – Mail Function in PHP

php-training-in-gurgaon
Almost in every web application sending automated email by system is the common requirement. So, it’s very common and important part that must be known by developer. The simple example, when a visitor to your website fills out a enquiry form. mail function return a boolen value, return true if email sent successfully, false otherwise  Syntax: mail ($to , $subject , $message, $additional_headers); $to: This is the first parameter of mail function hold the email address of receiver, the address to which email has to be sent. $subject: Every email should have subject. This parameter cannot contain any newline characters. $message: This is the actual body or content of email to send.  Please note that every line should be break by \n and every line should not exceed the limit…
Read More

Introduction to Ajax

php-training-in-gurgaon
Ajax (Asynchronous Java script And XML)  Introduction In Jesse Garrett’s original article that coined the term, it was AJAX. The “X” in AJAX really stands for XML HTTP Request though, and not XML. Jesse later conceded that Ajax should be a word and not an acronym and updated his article to reflect his change in heart. So “Ajax” is the correct casing. As its name implies, Ajax relies primarily on two technologies to work: JavaScript and the XML HTTP Request. Standardization of the browser DOM (Document Object Model) and DHTML also play an important part in Ajax’s success, but for the purposes of our discussion we won’t examine these technologies in depth. How Ajax Works At the heart of Ajax is the ability to communicate with a Web server asynchronously without taking away the…
Read More

The do-while loop

php-training-in-gurgaon
Difference Between while and do…while Loop: With a while loop, the condition to be evaluated is tested at the beginning of each loop statement, so if the conditional expression evaluates to false, the loop will never be executed. With a do-while loop, on the other hand, the loop will always be executed once, even if the conditional expression is false, because the condition is evaluated at the end of the loop statement. Example: <?php $i = 1; do { $i++; echo  $i . "<br>"; } while($i <= 3); ?>  Output: 2 3 4
Read More

The While Loop

php-training-in-gurgaon
A While loop is used when we have to repeat a set of statements as long as the condition is false. It could be the best where number of repetition is not known earlier or in advance. It can be explain in plain English as "Keep doing something until a condition is true". Syntax: while (condition) { //  Set of statements goes here; } Example <?php $ct=5; while($ct<=50) { echo  $ct . "<br>"; $ct = $ct+5; } ?> Output: 5 10 15 20 25 30 35 40 45 50 The do…while loop example: <?php $i = 1; do { $i++; echo  $i . "<br>"; } while($i <= 3); ?>  Output: 2 3 4 Difference Between while and do…while Loop: With a while loop, the condition to be evaluated is tested…
Read More

PHP -Building Blocks

php-training-in-gurgaon
If –else statements: if…else statement – executes set of codes if a condition is true and another code if the condition is false Within a statement, if a certain condition is true, then something happens. Otherwise, something else happens. We can continue adding else statements as many times as we need. So, within PHP statement, we first define the variable and then set up the conditional statements like this: Syntax: if (condition) code to be executed if condition is true; elseif (condition) code to be executed if condition is true; else code to be executed if condition is false; Example 1: <?php $avg = 50 if ($avg>60) { echo "You have a good score"; } else { echo "Score is less than average"; } ?> Example 2:  <?php $status =…
Read More