0% found this document useful (0 votes)
26 views2 pages

Assgnmnt

The document provides an overview of basic PHP syntax and commands. It explains that a PHP scripting block starts with <?php and ends with ?>, and can be placed anywhere in an HTML document. Variables in PHP start with $ and don't require declaration. It also demonstrates the print, concatenation, strlen(), and strpos() functions, and covers PHP comments, file extensions, and conditional statements like if, if/else, if/elseif/else, and switch.

Uploaded by

Mohd Siraj
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

Assgnmnt

The document provides an overview of basic PHP syntax and commands. It explains that a PHP scripting block starts with <?php and ends with ?>, and can be placed anywhere in an HTML document. Variables in PHP start with $ and don't require declaration. It also demonstrates the print, concatenation, strlen(), and strpos() functions, and covers PHP comments, file extensions, and conditional statements like if, if/else, if/elseif/else, and switch.

Uploaded by

Mohd Siraj
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

BASIC SYNTAX AND COMMANDS. A PHP scripting block always starts with <?php and ends with ?>.

A PHP scripting block can be placed anywhere in the document. A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code. Example: <?php Print " hei"; ?> output: The above php script will send the text "hei" to the browser. 1.Each code line in PHP must end with a semicolon. 2.The file must have a .php extension. If the file has a .html extension, the PHP code will not be executed. Comments in php: In PHP, we use // to make a single-line comment or /* and */ to make a large comment block. Declaring a variable: All variables in PHP start with a $ sign symbol.In PHP, a variable does not need to be declared before adding a value to it.A variable name should not contain spaces. Syntax: $var_name=value; Example: <?php $x=7; print"$x"; ?> output: The above script will create one variable containing a number. The Concatenation Operator: The concatenation operator (.) is used to put two string values together. <?php $x="hei!! "; $y="how are you"; print "$x"."$y"; ?>

The strlen() function: Finds the length of the string. Example: <?php $x= hei.wassup?; print "strlen($x)"; ?> The output of the code will be: 11 The strpos() function: This function will return the position of the character to be searched for, within a string. Example: <?php $x= "national institute"; Print "strpos($x, "institute")"; The output will be: 9

Conditional Statements

if statement - use this statement to execute some code only if a specified condition is true if...else statement - use this statement to execute some code if a condition is true and another code if the condition is false if...elseif....else statement - use this statement to select one of several blocks of code to be executed switch statement - use this statement to select one of many blocks of code to be executed

You might also like