Skip to main content

Advanced PHP

This segment will concentrate on some progressed PHP points, which will engage the per user to make dynamic web pages.

 A global variable is a variable declared at the top of the script outside the function. This variable is available to the complete script. Superglobal variables are arrays built into PHP. These superglobal variables are populated automatically with useful elements, and they are available in any scope. A superglobal array can be accessed within a function or a method without using the global keyword.

PHP Superglobals

  • $_COOKIE – It contains values provided to the script via HTTP cookies.
  • $_GET – It contains variables submitted to the script using HTTP get method. 
  • $_POST – It contains variables submitted to the script using HTTP post method. 
  • $_REQUEST – It is a combined array containing values from the $_GET, $_POST, and $_COOKIES superglobal arrays. 
  • $_ENV – It contains keys and values set by the script’s shell. 
  • $_FILES – It contains information about uploaded files. 
  • $_SERVER – It contains variables made available by the server. 
  • $GLOBALS – It contains all the global variables associated with the current script.

Instanceof Operator
The instanceof operator in PHP is used to determine whether a given object, the parents of that object, or its implemented interfaces are of a specified object class.
Example
<?php
class X { }
class Y { }
$thing = new X;
if ($thing instanceof X) {
echo 'X';
}
if ($thing instanceof Y) {
echo 'Y';
}
?>

Declare
The declare statement is used to set execution directives for a block of code. The syntax of the declare statement is similar to the syntax of other flow control statements.
Syntax
declare (directive)
statement

The directive section allows the behavior of the declare block to be set. In this only one directive is recognized, which is the ticks directive.
[Ticks - A tick is an event that occurs for every N low level statements, which are executed within the declare block. The value of N is specified using the statement ticks = N in the directive section.]
The statement partof the declare block will be executed according to the directives set in the directive block.
Example
<?php
// how to use declare:
// the first way:
declare(ticks=1) {
// entire script here
}
// the second way:
declare(ticks=1);
// entire script here
?>

For  more information, please visit: http://www.osglsofttech.com
Call: +91-8650030309, +91-8650030308

Address : TBI-GEU, 566/6 Bell Road, Clement Town, Dehradun-248002
Headoffice : 131, First Floor, PKT-9, Sector-5, North-East Delhi-110085

Comments

Popular posts from this blog

Why use an Inventory Management System?

Inventory management   software is a computer-based   system  for tracking   inventory  levels, orders, sales and deliveries. It can also be   used  in the manufacturing industry to create a work order, bill of materials and other production-related documents. Inventory  control is also  important  to maintaining the right balance of stock in your warehouses. You don't want to lose a sale because you didn't have enough  inventory  to fill an order. ... Too much  inventory  can trigger profit losses––whether a product expires, gets damaged, or goes out of season. ·          Real-Time Inventory by Category & Location Real time inventory provides comprehensive information’s in a format you currently use within a minute of the physical audit to be completed.   Real-Time Inventory   Control Software package allows you to manage all aspects of you...

Why Mobile Apps are Better Than Mobile Websites

The   number of mobile users  today is greater than the number of desktop users! Consequently, businesses have realized the need to effectively use mobile channels for attracting customers. They have started new operations (or scaled existing ones) through mobile websites and mobile apps. While businesses with large wallets can afford to employ both mobile websites and apps , other companies might have to choose one of them. The choice between mobile apps and websites depends on their cost, usability, required features and the audience they serve. That being said,  studies show  that users prefer mobile apps more than mobile websites . This makes for a strong reason to have mobile apps for reaching out to potential (and existing) customers. ·         Mobile Apps Offer Better Personalization Personalization is about offering tailored communication to users based on their interests, location, usage behavior, and more. Wi...

Learn New Programming Languages Groovy, Rust, Elixir, Go

Groovy Groovy  is an  object-oriented scripting language  that was created by Apache  for the Java platform . It appeared first in 2003, however the first stable release (Groovy 1.0) came out only in 2007. Since then, it has been used by companies such as  Netflix, Linkedin, Airbus, and Mastercard . Groovy is  dynamically compiled to Java bytecode , therefore it  seamlessly integrates with any Java library . If you’ve already programmed in Java or any other language that  uses the curly-bracket syntax  you can  learn Groovy relatively quickly . As Groovy is  open-source , you can find the  source code on Github , or you can contribute to the project yourself if you want. Although Groovy is usually praised because it  increases developers’ productivity ,  access to the Grails Web Application Framework  can also be a good reason to give a closer look to it. Grails was initially called  “...