Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

What is a client, Server, Internal Data Types, and Variables in PHP?

Php Introduction

PHP is an open Source Server-side programming/ Scripting language that suited for web development and can be embedded into HTML. PHP stands for Hypertext Preprocessor But it’s original name is Personal HomePage. it was developed in 1994. It runs in various platforms like Windows, Linux, Mac, etc. It is compatible with almost all servers like Apache, IIS, etc. Its File Extension is .php.

What is a client?

A client is a piece of computer hardware or software that accesses a service which made available by Server. For example, a web browser is clients that connect to web servers and retrieve web pages for display.

What is a Server?

a server is a Computer program or a device that provides functionality for other programs or a device called client.

Ex- A client requests for a webpage then server finds that webpage and display on the client’s screen.

Client-Server Architecture?

i. 2-tier Architecture In this architecture, only two are involved. First who request, and 2nd Who Fulfill the request. It means, Client Directly communicates with the Server and Sends request, and the server responds to the client.

ii. 3-tier Architecture – In this architecture, there is a middleware is used to fulfil the request. When a Client request for a webpage, then application server first check-in data source that the requested webpage is available or not, if available then the server responds to the Client.

What is a Web Browser?

A Web browser is a client, program, software or tool through which we send an HTTP request to the Web Server. It knows how to communicate with the server. The main purpose of a web browser is to locate the content on the World Wide Web and display the pages, images, audio, and videos. For example- Google Chrome, Mozilla Firefox, etc.

What is a Web Server?

A Web Server can be either a software or hardware unit, which provides the web pages via HTTP. It gets the request and find the resources, then respond to the Client. Web Server provides services only for web applications. All communication between client and server takes place through HTTP. For Example- tomcat, IIS, SMTP, FTP etc.

Web Server Architecture – When Client Sends a request for a webpage, then Web Server first check that the requested page/source is available or not, if available then Web Server sends the request to the client and display.

How PHP Works?

When a Client request for a Webpage (suppose tutorial.php) to the server(here server is Apache) then server sends the request to the PHP interpreter which converts the request into machine language and then search that page in database, if the page was found in the database then it comes to PHP interpreter and interpreter sends the data to the Web Server. Now, Web Server sends the request-response to the client. See the below Image.

Variables in PHP?

Variables are containers which are used to store information.
Types of variable :-
i. Local variable.
ii. Globle variable.
iii. Static variable.

How to declare a variable in PHP?

In PHP, Variable names begin with $ sign, followed by a name.
For Example – $roll
$price
$name

Rules of Variable names?

  • Variable start with $ sign.
  • Variable name only starts with a letter, an underscore(_).
  • A variable name cannot start with a number.
  • It is case sensitive which implies that the variable num in lowercase is different from NUM in uppercase.
  • Do not use predefined constant name e.g. PHP_VERSION, PHP_OS etc.
  • Do not use a reserved keyword. e.g. else, if etc.

How to Initialise Variables?

PHP can store all type of data in variables. Before using a variable in PHP, assign a value to it so PHP will create that variable and store data in it. That means we have to assign data to a variable before attempting to read a variable’s value.
For Example – $roll = 256;
$price = 23.28;
$name = Sushant;
Note – If a Variable is created without a value, it is automatically assigned a value NULL.

Internal Data Types

In other languages, you need to specify the exact data format of each variable, but PHP handles that for you.

  • Integer: It can hold the whole number. Ex: 12,0,-34 etc
  • Float/Double: It can hold a floating-point number. Ex: 26.35658, 3.25 etc
  • String: It can hold text or group of characters. Ex: “Sushant Kumar” etc.
  • Boolean: It can hold true/false value.
  • Array: It can hold multiple values in one single variable.
  • Object: It can hold programming objects.
  • NULL: It can hold only one value – NULL.

Click Here For Next Part – Echo Statement, Print Statement, and Here document in PHP.