Skip to main content

Some basic concepts of PHP

Sometimes some basic thing in PHP confuses us a Lot e.g difference between double quotes and single quotes , difference between echo and print etc. Although when we use these on one another place then everything works fine but there is some basic difference between the working of those. so today we going to understand some such type of basic things in PHP.

Single Quotes and Double Quotes
    Single quotes will just put exactly what is inside it single quotes can never sense any variable in its scope but Double quotes will evaluate first what is given in it. e.g.

 $variable = 'some string';
  echo '$variable';     // Output will be $variable
 echo "$variable";     // Output will be Some string

But if we use it for a simple string then output will be same in both cases and also the biggest difference between both it their processing speed. Single quotes are much faster that double quotes. its quite difficult to see in small programs. if you got a 1500 times a loop then you can easily see the difference.

echo and print
     Echo and print both are use to output the information on user's screen but the difference is that print can return true or false means its useful if we want to use it in loop but echo is different it doesn't returns any value that's why it is faster than print otherwise the use of echo and print is save.

Use Nested Quotes
     if you want to use Quotes inside the quotes means double quotes inside double quotes then you have to 'escape' them eg
 
  echo "this is "an example"";



this is not gonna work because when it will show an error to use nested quotes you have to escape them with backslash (\). you can do that in following manner.

 
echo "this is \" an example \"";



the above given code will work fine. So these were some basic thing about PHP for beginners hope this  will help.
   

Comments

Popular posts from this blog

Network Topologies (Tutorial-4)

Topology refers to the way in which the network of computers is connected. The choice of topology is dependent upon--- Type and number of equipment being used  Planned applications and rate of data transfers  Required response times  Cost Types of Network Topologies Physical Topology: Physical topology defines how devices are connected to the network through the actual cables that transmit data(physical structure of the network)  Logical Topology: Logical Topology (also referred to as Signal Topology) is a network computing term used to describe the arrangement of devices on a network and how they communicate with one another.

Networking (Tutorial-8) IEEE Standards

IEEE INTRODUCTION Institute of Electrical And Electronics professional organization for the advancement of technology related to electricity.  Formed in 1963 by the merger of IRE( Institute of Radio Engineers ) and AIEE(American Institute of Electrical Engineering)  IEEE is one of the leading standards-making organizations in the world. IEEE performs its standards making and maintaining functions through the IEEE Standards Association(IEEE-SA).  IEEE Standards The Institute of Electrical and Electronics Engineers Standards Association (IEEE-SA) is a leading developer of global industry standards in a broad-range of industries, including:  Power and Energy  Biomedical and Healthcare  Information Technology  Telecommunications  Transportation  Nanotechnology  Information Assurance  Development of IEEE Standards The IEEE standards development process can be broken down into seven basic steps, as follows: ...

Cisco Hierarchical Model

Cisco Hierarchical Model Defined by Cisco to simplify the design, implementation, and maintenance of responsive, scalable, reliable, and cost-effective networks. The 3 layers are logical and not physical – there may be many devices in a single layer, or a single device may perform the functions of 2 layers, eg: core and distribution. The Cisco Hierarchical Model