Table of encoded characters جدول تكويد الأحرف الخاصة







2. Escaping Double and Single Quotes


Another essential PHP function that comes in handy when passing data to JavaScript is addslashes which will add a backslash before: backslashes, single- and double-quotes.


For example, to echo a PHP variable into JavaScript code:


... onclick="return confirm('Delete this item: <?PHP echo addslashes($name) ?>?';" ...

In the HTML we use double-quotes and in the JavaScript single-quotes, so any quotes within the JavaScript code will need to be escaped so that they don't conflict with either the HTML or JavaScript quotes.


For more details on escaping PHP variables for use in JavaScript see our related article: Passing PHP variables to JavaScript.


3. Table of encoded characters


Here you can see how the various JavaScript and PHP functions apply to a range of common characters.
































































































































































Input JavaScript PHP
  escape encodeURI encodeURIComponent urlencode rawurlencode htmlentities
<space> %20 %20 %20 + %20  
! %21 ! ! %21 %21 !
@ @ @ %40 %40 %40 @
# %23 # %23 %23 %23 #
$ %24 $ %24 %24 %24 $
% %25 %25 %25 %25 %25 %
^ %5E %5E %5E %5E %5E ^
& %26 & %26 %26 %26 &amp;
* * * * %2A %2A *
( %28 ( ( %28 %28 (
) %29 ) ) %29 %29 )
- - - - - - -
_ _ _ _ _ _ _
= %3D = %3D %3D %3D =
+ + + %2B %2B %2B +
: %3A : %3A %3A %3A



مواضيع متعلقة


اهم الفاعليات لهذا الشهر


الشبكات الإجتماعية

تغريدات تويتر