A valid variable name:
- Starts with a dollar sign ($)
- Followed by either a letter or underscore
- Can contain numbers, numbers, underscores, dashes (hyphen)
- Case-Sensitive
- No spaces
$Products; $salePrice; $sale_price; $item3; $_itemName; $__itemPrice;Avoid these variable format:
$_itemPrice; //PHP defined variables, $_POST, $_GET etc. $__itemPrice; //double/triple/four underscore can be confusingLets take Variables in action:
<html> <head> <title>PHP Variables</title> </head> <body> <?php $price1 = 25; echo $price1 . '<br />'; $products = 'product lowercase'; $Products = 'product uppercase'; echo $products . '<br />'; echo $Products . '<br />'; $price1 = 500; echo $price1; ?> </body> </html>
No comments:
Post a Comment