Skip to main content

PHP Introduction and Variables, Operators in PHP

PHP Introduction:

  • Rasmus Lerdorf is the founder of the PHP in 1995.
  • PHP is the server side scripting language.
  • Php needs a server to excute the file.
  • Php files should be saved with .php as its extension “.php3”, or “.phtml”
  • Or else our server will not excute unknown extension apart from .html, .cpi, .cgs,
  • Php support all the data base . that present in the market
Ex:-mySql,mssql,infonix,Sybase,ibmdb2,postgresql………etc
  • Php can be worked on all the operating systems that is windows,linux,max,solaries…etc
  • Php can communicate with different servers
Ex:-SMTP(Simple mail transfer protocal),imap (internet max access protocal), LDAP, Informix, Oracle, Sybase, Solid, PostgreSQL
  • PHP  can be install as a software tags we get many of the server files
Ex: -Xampp, Wamp, easy php, mamp
  • PHP stands for PHP: Hypertext Preprocessor
  • PHP is an open source software
  • PHP is free to download and use
  • PHP is easy to learn and runs efficiently on the server side
Xampp: – xampp stands for
x—————————–>platform(windows,linux,mac,solaries)
a—————————–>apache(web server)
m—————————->mysql(database file)
p—————————->perl(perl scripting in php)
p—————————->php/my admin (web database tool)
php current version is 5.3.8
wamp: – wamp stands for
w—————————->window exv
a—————————–>apache(web server)
m—————————->mysql(database file)
p—————————->php/my admin (web database tool)
Mamp: – mamp stands for
m—————————–>mac ‘os’
a—————————–>apache(web server)
m—————————->mysql(database file)
p—————————->php/my admin (web database tool)
Apache contain the  1-65535 ports                                1-1024 pre-reserved ports
Tem: – temp holds session details & temp upload files
Htdocs: – after installing xampp we have to store our files into the folder called htdocs. Once files are saved in htdocs we can open with the location path as
HTTP://LOCALHOST/ABC(FOLDER name)/first.php
 echo:-echo is the output method in php
BASIC PHP SYNTAX:-
COMMENTS IN PHP:-
In PHP, we use // to make a one-line comment or /* and */ to make a comment block:
PRINTING METHODS IN PHP:-
Echo:-echo as the arguments can print multiple arguments. Echo as a function can print only one argument
Print: -print as an argument can print only one argument.print also a function
Ex: – print”arg
”;
Printf: – printf will take formatting string with respected values as print
Ex: –printf(“(int%d) (float%f) (string %s) (asci%c)”);
Print-r: – print-r will print array of string
Ex: – $g = array (10,20,30,true,’kalam’);
Print-r($g);
Var-dump: –it is also printing method which is used debugging the errors very easily. This not used in production level (live environmental)
CONTROLLING:-
VARIABLES
  • Variables are “containers” for storing information.
  • Variables in PHP starts with a $ sign, followed by the name of the variable
  • The variable name must begin with a letter or the underscore character
  • A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _)
  • A variable name should not contain spaces
  • Variable names are case sensitive (y and Y are two different variables)
  • In PHP, a variable does not need to be declared before adding a value to it.
  • In the example above, notice that we did not have to tell PHP which data type the variable is.
  • PHP automatically converts the variable to the correct data type, depending on its value.
  • In a strongly typed programming language, you have to declare (define) the type and name of the variable before using it.
Related Page: Data Types In PHP
PHP has four different variable
  • local
  • global
  • static
  • Super global array of variable
1) LOCAL VARIABLE:-
A variable declared within a PHP function is local and can only be accessed within that function.
2) STATIC VARIABLE:-
When a function is completed, all of its variables are normally deleted. However, sometimes you want a local variable to not be deleted.
To do this, use the static keyword when you first declare the variable.
3) GLOBAL VARIABLE:-
Global scope refers to any variable that is defined outside of any function.
Global variables can be accessed from any part of the script that is not inside a function.
To access a global variable from within a function, use the global keyword:
4) SUPER GLOBAL ARRAY OF VARIABLE:-
$global is the super global array variable. This is the pre-defined keyword. In php we have mainly some of the super global variables. This can be used with their keywords.
i) $_EVN: – this is used for getting the information of your operating system ($_ENV (PATH))
ii) $_SERVER: – will give you the information about your server(apache information)
iii) $_GET: – it is used for form processing through get method (or) query string
iv) $_POST: –this is used for form processing through post method in secure manner
v) $_REQUEST: –will send the form through both get and post and cookie
vi)$_COOKIE: – this is used to get the information about the browser who is using the web(computer)
vii)$_SESSION: –it is used to get the information of the user in between login and logout details are store at server machine
OPERATORS
1. Assignment operator:    = is used to assign values to variables in PHP
2. Arithmetic operator:         +,-,/,*,%
3. Increment & decrement operator:     i++,++I  & i–, –i
4. Comparison operator:      ==,!= ,===
5. Relational operator: <=, >=, <>
6. Logical operator: &&, ||, and, or
7. Error handling operator:  –
8. scope resolution & this operator:    ::—–>scope,   &——->this
Ex: -operator.php
     //@TEST();
TYPE CASTING:-
Conversion of the one data type into another data type is known as type casting. in php we have mainly two types of casting
1. Temporary type casting
2. Permanent type casting
1. Temporary type casting: – casting which can be done for single step by pre-defined the data type keyword. That particular variable will hold Temporary type casting
2. Permanent type casting: – this can be done by using pre-defined key-word set type.which hold two arguments
Syntax: – set type (var name,’int’);
TYPE JUGGLING:-
conversion of data types by using expression to another data types are  known as type juggling
VARIABLE VALIDATION FUNCTION:-
i) Isset: –Isset of variables will check with the variable initialize are not and return Boolean
ii) empty(var name): – empty function will check the variable are not and return Boolean
iii) Unset (var name): –this function will remove the variable (or) delete the variable (or) initialize variable
iv) get type(var name): – this function will let us known the argument the data type in the form of string .this should be used because the coming variable this would be depreciated

Comments

Popular posts from this blog

CommVault Web Serach Interface 7.0 for Users

The Business Challenge Data boom maintains to place strain on information technology (IT) infrastructures, traumatic ever increasing budgets and gadget. Unstructured report structures and email data present challenges in growth and control, due to the character of how and whilst the data is created. customers are normally now not aware of quotas, and are normally disorganized in saving and naming their files and in dealing with their email folders. This makes it more tough to decide which files and messages are commercial enterprise-essential and which can be retired to help control data increase. This data chaos additionally makes it difficult for directors to help customers to find lacking or lost files while required. The CommVault® solution CommVault® offers a notably higher approach that gets rid of the tiers of separation typically found between users and their data. in place of requiring users to work through a help table and management groups to find and recover their d...

Packet Tracer vs a Real CCENT or CCNA Lab

So virtualization has come a long way…right?  Sure it absolutely has.  But what about in helping you prepare for your Cisco CCENT or CCNA exam ?  Well you have heard the saying that there is nothing like the real thing…right?  Well I have to agree with it for those of you who are preparing for your CCENT and CCNA exams.  Now let me say that I do feel that there is a place for simulators.  But that is usually reserved for the situations in which someone cannot afford a lab or when you are at a CCNP level and you just need to simulate a certain technology that it may not make sense to spend $500 to see a single concept work.  It is in those situations that the simulator is generally being used by someone who is a senior network engineer that clearly understands the foundation of the CCNA exam and is simply looking to augment a small part of their skill set. EIGRP CCENT & CCNA Lab So let’s bring it back down to a CCNA level.  Why do I frown...

What are The Benefits of Learning Robotic Process Automation?

Robotic Process Automation Introduction: People dependably consider making their life less requesting, snappier and beneficial with improved gainfulness, capability, and ampleness towards dealing with their issues and fulfilling their requirements in a simple way. With the approach of PCs, enormous limit of data and calculations wound up possible with a single mouse click. However, in the meantime, a human was relied upon to work the structure. By and by, the routinely creating advancement will allow taking individuals too out from the condition. Also, this endeavor has accomplished new tops at exponential speeds. We, people, have continually tended to accomplish a frequently extending number of things by the machines and particularly those things which the machines could improve the conditions superior to us. Before Computers showed up, individuals used to do all the constant work with limited means available inside reach. In this article, I will talk about why we are hearing a consid...