Skip to main content

String Variable in PHP

$coats1 = "Winter Coats";

Again, our variable name starts with a dollar sign ($).

We've then given it the name coats1. The equals sign follows the variable name. After the equals sign, however, we have direct text - Winter Coats. Then you can also put text into your variables.

Assume you want to know something about the coats you own. Are they Winter coats? Jackets? Summer coats? You decide to catalogue this, as well. You can put direct text into your variables. You do it in a similar way to storing numbers:

j2program


But notice the double quotation marks around our text. If you don't surround your direct text with quotation marks, then you'll get errors. You can, however, use single quotes instead of double quotes. So you can do this:

$coats1 = 'Winter Coats';

But you can't do this:

$coats1 = 'Winter Coats";

In the above line, we've started with a single quote and ended with a double quote. This will get you an error.

We can store other text in the same way:
Samurdhika
ICT Lecture Samurdhika

$coats2 = "Jackets";

$coats3 = "Summer Coats";

The direct text will then get stored in the variable to the left of the equals sign.

So, to recap, variables are storage areas. You use these storage areas to manipulate things like text and numbers.

You'll be using variables a lot, and on the next few pages you'll see how they work in practice.

Comments

Popular posts from this blog

Ministry of Higher Education Project : SLIATE (live project)

ABOUT SLIATE Our Mission  "Creating Excellent Higher National and National Diplomates with Modern Technology for Sustainable Development" Our Vision "To Become the Centre of Excellence in Technological Education" As per the recommendations of the Committee appointed by Prof. Wiswa Waranapala, Deputy Minister of Higher Education in 1994, the Sri Lanka Institute of Advanced Technical Education (SLIATE) was formed in 1995, under the Sri Lanka Institute of Advanced Technical Education Act No. 29 of 1995, In 2001 the name of the institution was amended as Sri Lanka Institute of Advanced Technological Education, (SLIATE). It functions as an autonomous Institute for the management of Higher National and National Diploma courses. The main purposes of establishing SLIATE were to reform and restructure the entire technical and vocational education system in relation to the changing needs of economic development, to meet manpower requirements of natio...

What is Google Adwords Certification Program

What is Google Adwords Certification Program? Google Certification Program is a program through which an individual can earn one of the most valuable status of being a google adwords qualified individual or a company can earn a google adwords certified partner status. Google Adwords Certification wiil show your knowledge, skills and proficiency in google adwords latest tools and it will show that an individual or a company know how to design, implement and manage an adwords campaign and they will use best practices and techniques and follow google adwords policies and guidelines which is one of the most important thing in eyes of Google. Google has launched two types of certification program for Adwords: Individual Qualification. Company Certification. Individual Qualification Individuals who want to add more value to there resume or an individual who want learn google adwords and get certified can study and get Google Adwords Qualified Individual also known as Google Adwo...

Micro Loan Banking Management System