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

Data Sending Ways in PHP

php-training-in-gurgaon
There are some certain ways to send your information or data to the PHP page- Using Form Methods - Get & Post Using Cookies & Session Using Query String / URL Rewriting Using Hidden form fieldForm MethodsThe GET Method: The GET method sends information separated by the ? Operator.Example: http://www.xyz.com/home.html?city=Gurgaon Please note that the GET method is restricted to send upto 1024 characters (1024 bytes) only. You should not use GET method if you have password or other confidential information to be proceeding over the server. GET can't be used to send binary data, like images or word documents, to the server. The PHP provides $_GET associative array or super global variable to access the data sent using GET method. The POST Method The POST method transfers information via HTTP…
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

Managing Sessions & Cookies

php-training-in-gurgaon
The basic task of both cookies and sessions is to store visitor data so that it can be accessed by every page on a website. Cookies: Cookies are small text files that are stored in the visitor's browser for a specific time or for a long  -lifespan. Cookies can be edited by the visitor.  in short Cookies are client-side files that contain user information. Sessions: Sessions are small files that are stored on the website's server. Sessions have a limited lifespan, they expire when the browser is closed or logged out from the session. Sessions cannot be edited by the visitor or user. Session Max life time is 1440 Seconds(24 Minutes) as defined in php.ini file however you may change it accordingly In short, cookies serve on the visitor's computer…
Read More