user4274597
user4274597

Reputation:

How to add variable in error message (php) multilanguage?

Need error message in two languages, and have some trouble with single quotes... This is how it looks like:

else if(trim($FullName) == '')
    $error = '<div class="errormsg">Please enter your Full Name!</div>';
}

And how when I put variable

else if(trim($FullName) == '')
    $error = '<div class="errormsg"><?php echo $lang['error']; ?></div>';
 }

So, when I put it like this, syntax becomes incorrect because single quotes..

Upvotes: 0

Views: 84

Answers (2)

Pedro Lobito
Pedro Lobito

Reputation: 98971

I would use empty, i.e.:

else if(empty(trim($FullName)))
    $error = '<div class="errormsg">Please enter your Full Name!</div>';
}

the following, doesn't make sense since you're inside a php block:

$error = '<div class="errormsg"><?php echo $lang['error']; ?></div>

Change for:

else if(empty(trim($FullName)))
    $error = '<div class="errormsg">'.$lang['error'].'</div>';
 }

Upvotes: 1

Cr3aHal0
Cr3aHal0

Reputation: 809

did u try

else if(trim($FullName) == '')
    $error = '<div class="errormsg">'. $lang["error"] .'</div>';
 }

EDIT : echo is a php instruction that does not require you to re-open and re-close php tags (<?php and ?>). You can compute strings thanks to concatenation which is some basic stuff in PHP

Upvotes: 1

Related Questions