Php addslashes Function

Source: Internet
Author: User

Php addslashes function finally corresponds to the c function: 3244 PHPAPI char * php_addslashes_ex (char * str, int length, int * new_length, int should_free, int ignore_sybase TS RMLS_DC) 3245 {3246/* maximum string length, worst case situation */3247 char * new_str; 3248 char * source, * target; 3249 char * end; 3250 int local_new_length; 3251 3252 if (! New_length) {3253 new_length = & local_new_length; 3254} 3255 if (! Str) {3256 * new_length = 0; 3257 return str; 3258} 3259 new_str = (char *) safe_emalloc (2, (length? Length: (length = strlen (str), 1); 3260 source = str; 3261 end = source + length; 3262 target = new_str; 3263 3264 if (! Ignore_sybase & PG (magic_quotes_sybase) {3265 while (source <end) {3266 switch (* source) {3267 case '\ 0 ': 3268 * target ++ = '\'; 3269 * target ++ = '0'; 3270 break; 3271 case '\'': 3272 * target ++ = '\ ''; 3273 * target ++ =' \''; 3274 break; 3275 default: 3276 * target ++ = * source; 3277 break; 3278} 3279 source ++; 3280} 3281} else {3282 while (source <end) {3283 switch (* source) {3284 case '\ 0 ': 3285 * target ++ = '\'; 3286 * target ++ = '0'; 3287 break; 3288 case '\ '': 3289 case' \" ': 3290 case '\\': 3291 * target ++ = '\'; 3292/* break is missing * intentionally **/3293 default: 3294 * target ++ = * source; 3295 break; 3296} 3297 3298 source ++; 3299} 3300 3301 3302 * target = 0; 3303 * new_length = target-new_str; 3304 if (should_free) {3305 STR_FREE (str ); 3306} 3307 new_str = (char *) erealloc (new_str, * new_length + 1); 3 308 return new_str; 3309} from the above, the addslashes function processes single-byte bytes. However, gbk encoding is dual-byte. And 5c can be used as a dual-Byte Low Position.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.