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.

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

Windows 7 transformation pack for xp

As the windows 7 launched after that there are lot of screenshot available on the internet, There developer designed the transformation packs for xp to make it better lo0king like windows 7. There are some transformation packs for your xp. Download Vienna 2.5 – Windows 7 Transformation Pack (Mirror) Downloa d HFN Windows 7 Transformation Pack Download Windows 7 Transformation pack – NSFormation (Mirror) Download Vienna Transformation Pack v1