htmlspecialchars

Problematic Quotes in Javascript callFunction()

穿精又带淫゛_ 提交于 2019-12-11 14:26:45
问题 I would like to know how to maintain the ability to have both single and double quotes in text that I am passing to a JavaScript function with callFunction()? All three cases below appears to be failing. Mixing the single and double quotes will work but I would like to be able to use both single and double quotes in my text blocks. It is curious why the browser is evaluating html special characters before passing it to the Javascript function. Thanks, Robin <!doctype html> <html> <head> <meta

Saving and Displaying HTML and special characters in a mysql database safely?

允我心安 提交于 2019-12-11 13:06:45
问题 The title basically sums it up. I built a small blog but I cant even post links in my articles! What can I do? I've tried htmlentities() , htmlspecialchars() , real_escape_string() and basically every form of escape there is. I am using PHP 5.3 with MySQL 5.1 Here is my code to save the blog to the db: function check_input($data, $problem='') { $data = trim($data); $data = stripslashes($data); $data = htmlentities($data); if ($problem && strlen($data) == 0) { die($problem); } return $data; }

JSON specialchars JSON php 5.2.13

南楼画角 提交于 2019-12-11 08:38:42
问题 I'm getting crazy over these encoding probs... I use json_decode and json_encode to store and retrieve data. What I did find out is, that json always needs utf-8. No problem there. I give json 'hellö' in utf-8, in my DB it looks like hellu00f6 . Ok, codepoint. But when I use json_decode , it won't decode the codepoint back, so I still have hellu00f6 . Also, in php 5.2.13 it seems like there are still no optionial tags in JSON. How can I convert the codepoint caracters back to the correct

Laravel truncating strings with special characters

扶醉桌前 提交于 2019-12-11 08:17:14
问题 I have been working on a CMS for months now, I have faced various challenges with laravel truncating certain special characters. I had to change the editor in the CMS from bootstrap wysiwyg to ckeditor things got quite better as there are some advance escaping options that come with it. For example I was able to prevent '"' from becoming '" which was causing the entire string (paragraph) to truncate where ever it finds such encoding. However this is a CMS where the user has a good reason to

PHP csv import need help - Decimal values becomes rounded values when inserting into table

北战南征 提交于 2019-12-11 07:44:18
问题 I am trying to insert data into MySql table from csv file using PHP, please see this image - my CSV file. the problem i face is, while loading the CSV file, the net_sales column becomes rounded and inserted in the table. please see below sample image of MySql Table after inserting. FYI, here i am showing only net_sales column for explaining my problem, actually i have more columns in the table and CSV. due to some reasons, i cant have a static insert statement like this "insert into tran

Special characters UTF8 not displaying in safari

て烟熏妆下的殇ゞ 提交于 2019-12-11 06:09:25
问题 Ok i thought this where something easy to google, but the answers i found, did not fix my problem In Chrome my RSS feeds are looking like this "¿Qué es un serum antimanchas?" But all the rest characters are ok .. In Safari, is the oposit this line look fine but the rest of characters are wrong..and they look like Espect�culo I have this on my header wich it suppose to work, cant find the problem, <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD

Is there a way to send parameters into a callback function without creating my own function first?

北城以北 提交于 2019-12-10 14:03:27
问题 I have an array of values that I would like to run through htmlspecialchars but with an argument such as this: $param = htmlspecialchars($param, ENT_QUOTES); The problem is, I have an array of values that I want to run htmlspecialchars on: $array = array_map('htmlspecialchars', $array); and I would like to know if there is a way to pass ENT_QUOTES into the array_map callback? I can always use my own function that uses htmlspecialchars, but it would be nice if there was a way to do this

Escape only single quotes (leave double quotes alone) with htmlspecialchars()

无人久伴 提交于 2019-12-10 13:17:39
问题 I know there are other ways of of escaping only single quotes (such as this answer), but it appears to me that there should be a way using htmlspecialchars(). According to the manual, it should be some combination of their constants, but based on their explanations, I don't see it. Is it possible to escape only single quotes, leaving the double quotes alone, with htmlspecialchars() ? 回答1: str_replace("'", "\\'", $string); There. Or, use ENT_QUOTES htmlspecialchars($string, ENT_QUOTES); 回答2:

PHP htmlentities not working even with parameters

懵懂的女人 提交于 2019-12-10 13:08:50
问题 Of course this has been asked before and have searched for solutions, all which have not worked thus far. I want to change out the TM symbol and the ampersand to their html equivelents by using htmlentities or htmlspecialchars : $TEST = "Kold Locker™ & other stuff"; echo "ORGINIAL: " . $TEST . "<BR/>"; echo "HTML: " . htmlentities($TEST, ENT_COMPAT, 'UTF-8'); This displays: ORGINIAL: Kold Locker™ & other stuff HTML: I have also tried it with htmlspecialchars and the second parameter changed

htmlentities和htmlspecialchars 的区别

僤鯓⒐⒋嵵緔 提交于 2019-12-10 11:13:05
多人都以为htmlentities跟htmlspecialchars的功能是一样的,都是格式化html代码的,我以前也曾这么认为,但是今天我发现并不是这样的。 代码如下: '&' (ampersand) becomes '&' '"' (double quote) becomes '"' when ENT_NOQUOTES is not set. ''' (single quote) becomes ''' only when ENT_QUOTES is set. '<' (less than) becomes '<' '>' (greater than) becomes '>' htmlspecialchars 只转化上面这几个html代码,而 htmlentities 却会转化所有的html代码,连同里面的它无法识别的中文字符也给转化了。 我们可以拿一个简单的例子来做比较: 代码如下: $str='<a href="test.html">测试页面</a>'; echo htmlentities($str); // <a href="test.html">²âÊÔÒ³Ãæ</a> $str='<a href="test.html">测试页面</a>'; echo htmlspecialchars($str); // <a href="test.html">测试页面</a> 结论是