PHP Superglobals

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 i.e. IP address, Host name, query string, file name etc.

$_FILES – Is used to handle uploaded files operations in PHP. i.e. file size, type, name etc.

Example – $_SERVER Superglobals:

<?php

echo”Current IP Address is: “.$_SERVER[‘REMOTE_ADDR’];

echo “You are at page: “.$_SERVER[‘PHP_SELF’];

?>

 

Functions:

Functions in PHP behave similarly to functions in C. When we define the functions, we must specify what values the function can expect to receive.

So let’s create a function. We need to give the function a name and tell it what variables to expect. We also need to define the function before we call it.

<?php

function sum($f1, $f2)

{

$f3=$f1+$f2

return $f3;

}

echo sum(10,8);

?>

Output: 18

So First, we created our function. Notice how we defined two new variables, called $f1 and $f2. When we call the function, each variable is assigned a value based on the order in which it appears. Then we simply added the two numbers together and returned the result. “Return” here simply means to send the result back.

About Us

Luckily friends do ashamed to do suppose. Tried meant mr smile so. Exquisite behaviour as to middleton perfectly. Chicken no wishing waiting am. Say concerns dwelling graceful.

Services

Most Recent Posts

  • All Post
  • advanced-excel-training
  • Branding
  • deepti saini model
  • Development
  • Digital Marketing
  • digital marketing course gurgaon
  • Digital Marketing Internship Gurugram
  • digital marketing jobs
  • digital-marketing-institutes-sector-14
  • Leadership
  • Management
  • Notice
  • php-development-courses
  • php-full-stack-development-courses
  • php-job-opportunity
  • php-training
  • php-training-in-baksar
  • php-training-in-balia
  • php-training-in-bangalore
  • php-training-in-delhi
  • php-training-in-faridabad
  • php-training-in-gaziabad
  • php-training-in-gorakhpur
  • php-training-in-gurgaon
  • php-training-in-kolkata
  • php-training-in-muzaffarpur
  • php-training-in-noida
  • php-training-in-patna
  • placements
  • web development training gurgaon

Company Info

She wholly fat who window extent either formal. Removing welcomed.

Limited Seats Available – Register Now

We keep batch sizes limited so every learner gets personal attention and proper doubt solving. Reserve your seat now and start your training in the next batch without delay. For details call us +91- 8802000175

Help

Privacy Policy

Terms

Conditions

Subscribe Now

For latest news and updates, fill your details below-

You have been successfully Subscribed! Ops! Something went wrong, please try again.
© 2023 Created with Royal Elementor Addons