Reputation: 517
The problem in my assignment is to verify the length of a string(a phone number in this case) given in a form that is POSTed, and then create a substring consisting of a portion of the data given.
Specifically if the number is 6235551234, the selection should be 555.
$phone = $_POST['phone'];
if (strlen($phone) = 10) {
$phone_prefix = substr($phone, 3, 3);
} else {
echo 'Enter Proper phone number' ;
}
However for the code I receive this error.. "Fatal error: Can't use function return value in write context
Any ideas?"
Upvotes: 0
Views: 2176
Reputation: 10644
You try to assign value to function return
if (strlen($phone) = 10) {
You should have:
if (strlen($phone) == 10) {
Upvotes: 6