Posts

Showing posts from October, 2017

Differences

Image
Differences between constants and variables are as fallow:- There is no need to write a dollar sign ($) before a constant, where as in Variable one has to write a dollar sign. Constants cannot be defined by simple assignment, they may only be defined using the define() function. Constants may be defined and accessed anywhere without regard to variable scoping rules. Once the Constants have been set, may not be redefined or undefined.

Constants

Image
A Constant is a name or an Identifier for a simple Value. A Constant value cannot change during the Execution of the Script. By default, a constant is case sensitive. By convention, constant identifiers are always uppercase. A constant name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. If you have defined a constant, it can never be changed or undefined. To define a constant you have to use define() function and to retrieve the value of a constant, you have to simply specifying its name. Unlike with variables, you do not need to have a constant with a $. You can also use the function constant() to read a constant's value if you wish to obtain the constant's name Dynamically. constant() function As indicated by the name, this function will return the value of the constant. This is useful when you want to retrieve value of a constant, but you do not know its name, i.e. It is stored in a variable or returned by a f

Variables

Image
Variables are used to Store Information to be referenced and manipulated in a program. They also provide a way of labeling data with a descriptive name, so our programs can be understood more clearly by the reader and ourselves. It is helpful to think of variables as Containers that hold information. Their sole purpose is to label and store data in memory. This data can then be used throughout your program... Here are the most important things to know about variables in PHP. All variables in PHP are denoted with a leading dollar sign ($). The value of a variable is the value of its most recent assignment. Variables are assigned with the = operator, with the variable on the left-hand side and the expression to be evaluated on the right. Variables can, but do not need, to be declared before assignment. Variables in PHP do not have intrinsic types - a variable does not know in advance whether it will be used to store a number or a string of characters. Variables used before

Lecture # 3 Comments:-

Image
Commenting in PHP A Comment is a Programmer's Readable Explanation or Annotation in the Source Code of a Program. They are added with the purpose of making the Source Code Easier for Humans to understand, and are generally ignored by Compilers and Interpreters. Uses Planning and Reviewing Code Description Algorithmic Description Resource inclusion Metadata Debugging Automatic Documentation Generation Syntax Extension Stress Relief There are two commenting formats in PHP - 1. Single Line Comments 2. Multi Line Comments Single-line Comment They are generally used for short Explanations or notes relevant to the local code. Here are the examples of single line Comments. <?php      # This is a comment, and      # This is the second line of the comment       // This is a comment too. Each style comments only print           "An example with single line comments";  ?> Multi-lines Comments They are g