Unset() function means in php?

php-training-in-gurgaon
The behavior of unset()  inside of a function can vary depending on what type of variable you are attempting to destroy. If a globalized variable is unset() inside of a function, only the local variable is destroyed. The variable in the calling environment will retain the same value as before unset()  was called. Example <?php function destroy_foo() { global $foo; unset($foo); } $foo = 'bar'; destroy_foo(); echo $foo; ?>
Read More

Difference between require() and require_once()?

php-training-in-gurgaon
The require() and require_once() functions perform same work. Both functions will include and evaluates the specific file while executing the code. if include() is not able to find a specified file on location at that time it will throw a warning however, it will not stop script execution. For the same scenerio require() will throw fatal error and it will stop the script execution. Example <?php echo "Hello"; ?> test.php <?php require('echo.php'); require_once('echo.php'); ?> test.php outputs: "Hello".
Read More

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

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

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

Require () and Include () function in PHP

php-training-in-gurgaon
The Include() and require() statements are used to insert codes written in other files, in the flow of  execution. The main of using include and require functions to integrate one page code or content into another page. You can maintain usually some repeated functionality in the form of PHP file and finally you can call it wherever you want. See, the following example demonstrates how to integrate a menu content in other pages of PHP. There is a page in menu.php and it can be included in some other pages of the website. Menu.php <a href=”index.php”>Home</a> <a href=”services.php”>Services</a> <a href=”about.php”>About Us</a> <a href=”contact.php”>Contact Us</a> The following page index.php uses above menu.php content. See the below code how it follows <head> <title>My Web page</title> </head> <body> <?php include  “menu.php “; ?> </body> Difference between Include…
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

The For Loop

php-training-in-gurgaon
PHP for loop can be used to traverse set of code for the specified number of times. For example if you want to repeat something ten or twenty times. It should be used if number of iteration is known otherwise I recommend you to use while loop. Syntax: for (Initialization; Condition; Progressive) { //set of statements to be executed; } Parameters: Initialization: Initialize the loop counter value Condition: Check for condition. If it evaluates to TRUE, the loop continues. If FALSE then the loop ends. Progressive: Increase / Decrease the loop counter value Example: for($var=1; $var<=20; $var=$var+1) { echo $var ." "; } Output: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Example: to display 1st 20 natural…
Read More

PHP Superglobals

php-training-in-gurgaon
We already learned about variables, but there are some Readymade or predefined keywords in PHP that can be used without you having to create them first. Predefined or Superglobals variables are used to provide information from and about the web server, the web browser, and the user. There are several types of Super Global Variables:- $_GET - Is used to pass data through URL. Example: http://websjyoti.com?id=2 $_POST - Is used to pass data to server by hiding from URL. $_REQUEST – Is the combination of $_GET, $_POST, and $_COOKIE. $_SESSION - is used to maintain session and data from Local machine to Server. $_COOKIE – Is used to save/get user data on same machine in browser cookies. $_SERVER – Is an associative array which is used to know server information…
Read More

PHP – Date / Time Functions

php-training-in-gurgaon
When working in any programming language, dealing with dates and time is a simple task. That is, until time zones have to be supported. PHP's time () function gives you all the information that you need about the current date and time. It requires no arguments but returns an numeric value. If you will call to time() function which will return a set of numeric values which is difficult to understand. So to make it easy we can have time format along with the date() function. <?php $today = date("d/m/Y"); echo "Today is ".$today; ?> We can use different time format with separator like d-m-Y, d.m.Y and so on. Display Current Date and Time:  We can use the following characters to format the time string: <?php echo date("h:i:s") . "<br>";…
Read More