How to add javascript quotation around string in typo3

Many time we need to add quote around the syntax. when we particularly work for js ( javascript ).

If you have syntax like : fileadmin/_processed_/csm_0001_2137573116.jpg”;

and you want to use this syntax in your javascript then we need some quotation around syntax.

for that following script will do the trick

$string = "fileadmin/_processed_/csm_0001_2137573116.jpg";

$quoteString = \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($string);

After print of that result Output will look like below


it will add addtional quote around the string.

I hope it will work for you 😉 Njoy… 🙂

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s