In my webpage, I want the website to greet the user, but the username is surrounded by ‘single quotations’. Since this isn’t to prevent MySQL injection, i just want to remove quotes around my name on the display page.
Ex: Welcome ‘user’! I’m trying to find the way where i can strip the quotations around the user and have it display on the example below.
Ex: Welcome user!
The only line of code that I can think relating is this:
$login = $_SESSION[‘login’];
Does anyone know how to strip single lines quotes?
If you’re sure that the first and last characters of
$loginare always a'you can usesubstr()to do something likeYou can strip all
'from the string withstr_replace()Or you can use the
trim()function, which is in fact the same as example 1:My personal favorite is example 3, because it can easily be extended to strip away both quote types: