Do you want better
IT Services ?

Let our experts help you navigate the digital world with tailor-made IT Solutions!

Table of Contents

In previous chapter we learned about basics of PHP including php syntax, commenting in php and how to output in php using echo. In this chapter we will learn all about PHP variables.

What does Variable stands in PHP ? For a new learner this would be the most important thing to be learned. Variables are “containers” for storing information.

In Simple terms, if you want to store any information and retrieve it later, you need to store that information in a VARIABLE.

http://php.net says,

Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive.

Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.

 

[notification type=”notify” title=”To be Noted”]$this is a special variable that can’t be assigned.[/notification]

 

If we want to make a variable to store Names of students of class a good variable would be $Name instead of $blahblahblah. Again I would like to recall variables are CASE SENSITIVE. $footballmatch and $Footballmatch are different.

 

<?php
$name = 'David';

$scoreNumberValue = 48;

$scoreStringValue = '48';

/*
$name contains David,

we can use echo command to display David  
*/

echo $name;

/*
Now we also have used two more variables to store data,
and same data is stored in both that is 48, but there is a small difference. 

Case 1

$scoreNumberValue = 48;

this variable stores number 48 and
this can be used for mathematical calculations.
Data stored is without quotes.

Case 2 

$scoreStringValue = '48';

this variable stores data in quotes,
so php considers this as more of a string, so can not be used for
mathematical calculations
*/
?>

Hmm, that was easy, I hope you all learned something good out of this tutorial. Well this is beginning of something very good. The next chapter would cover Arithmetic Operators in PHP i.e how to do addition, subtraction, division, multiplication in php.

If you have any questions feel free to drop them in comments.

WordPress vs A Custom based php Website

WordPress and a custom PHP website are two different approaches to building a website. Here are some differences between the two: Ease of use: WordPress is generally easier to use than a custom PHP website, because it has a user-friendly interface and a large number of plugins and themes that allow you to easily add...

Read More

10 ways to bring targeted audience to your website

Search engine optimization (SEO): Optimizing your website for search engines can help bring targeted traffic from people searching for keywords related to your business. Pay-per-click (PPC) advertising: PPC advertising platforms like Google AdWords allow you to create ads that appear at the top of search engine results pages when people search for specific keywords. Content...

Read More

Top 8 Benefits of Having a Website

Top 8 Benefits of Having a Website Whether you’re a small business or a large corporation, having a website is essential to your success. In today’s digital world, people are used to getting their information online, and if you don’t have a website, you’re missing out on a huge opportunity. A website allows you to...

Read More

What is web hosting and why do I need it ?

Unless you are planning to build a website from scratch, you will need web hosting. Web hosting is a service that provides you with the technology and resources necessary to build and maintain a website. Think of it this way: if a website is like a house, then web hosting is like the land it’s...

Read More

How To Find The Right Website Designer For Your Business

A website is the face of your business – so it’s important that you take the time to find a designer who will create something that accurately represents your company. In this blog post, we’ll explore the process of selecting a designer, what you should keep in mind when hiring one, and how to go...

Read More

A Guide To Why You Need A Dynamic Website

The world has changed. The way people search for things have changed. The way they use technology to do their work have changed. Gone are the days when you create a website and take it as it is, customers will want more information, they’ll want better content, so you need to be ready to provide...

Read More
Scroll to Top
Scroll to Top

We help businesses with Websites, Mobile Applications, Digital Marketing, E Commerce Solutions & Custom Software.