SPECIAL OFFER: Only $69 for access to everything in OSTraining for 1 year! You save $75! 
Join today and get access to 1,000's of books and videos. Learn WordPress, Drupal, Magento, Joomla and more! Sign up today!

Input a string which contains an apostrophe

3 years 9 months ago - 3 years 9 months ago #123675 by Cockroach
I am looking how to write some PHP code which will permit an input of an apostrophe (') within the string. This is a user input, but I want to sanitize it for anything else unwanted.

The string is an individual's last name: D'Leon or O'Hara or O'Mally or O'Shanessey.

This routine is used by data operators without any PHP knowledge. The operators would not know to put in a "\" before the apostrophe. It is to be a routine within a data entry form.

Got any ideas how to do this? I have looked through several PHP guides & online guides. I am still looking but I thought you might run into this monthly or more frequently.

Please Log in to join the conversation.

3 years 9 months ago #123692 by Valentin
Replied by Valentin on topic Input a string which contains an apostrophe
Hi Cockroach,

May I have the current progress of this project to know how it looks right now? You can email us the files to support@ostraining.com - include the url of this forum topic in the message, then reply here

Kind regards,
Valentín

Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining
The following user(s) said Thank You: Cockroach

Please Log in to join the conversation.

3 years 9 months ago #123769 by Cockroach
Replied by Cockroach on topic Input a string which contains an apostrophe
Sorry about the late response. I think I found what I needed. For now, use a routine known as magic quotes will take care of it. It will process a name like this. Then there are routines add slashes & strip slashes. However, it looks like these programs will not be supported as separate routines much longer. They have been deprecated & HTML 6 will address this natively!

Roger

Please Log in to join the conversation.

3 years 9 months ago #123780 by Valentin
Replied by Valentin on topic Input a string which contains an apostrophe
Hi Roger,

If you're talking about this , yes, it's deprecated since PHP 5.3.

Let us know if we can be of any help

Kind regards,
Valentín

Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining

Please Log in to join the conversation.

Join today and get access to 1,000's of books and videos. Learn WordPress, Drupal, Magento, Joomla and more! Sign up today!