Question : php variable definition
Answered by : tiago-frana
## Regex:
## ^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$
// PHP validate variable name
$regex = '/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/i';
// Valid
preg_match($regex, '_aas', $matches);
[ "_aas",
]
// Valid
preg_match($regex, '_validVariable', $matches);
[ "_validVariable",
]
// Valid
preg_match($regex, 'oth3r_valid_variable', $matches);
[ "oth3r_valid_variable",
]
//Invalid
preg_match($regex, 'invalid Variable', $matches);
[]
//Invalid
preg_match($regex, '0th3r_invalid_vriable', $matches);
[]
//Invalid
preg_match($regex, '0th3r_invalid_variable', $matches);
[]
Source : https://www.php.net/manual/en/language.variables.basics.php | Last Update : Wed, 28 Sep 22
Question : how to make a variable in php
Answered by : weeper-capuchin-0ruafamuqafv
$varName = "Hello, World";
Source : | Last Update : Wed, 25 Dec 19
Question : how to declare variable in php
Answered by : ahmed-issah
<?php //declaring a variable in php $name = "Ahmed Issah"; $age = 23;
?>
Source : | Last Update : Sun, 31 Jul 22