RSS

PHP characters that need to be escaped

Sun, Nov 30, 2008

Server / Web Apps, Tips & Tricks

In writing PHP code, several characters need to be “escaped” for the code to run properly. If not, the browser will be blank or show errors.

The following characters have to be escaped, which means you write a backslash ( \ ) in front of it.

For example: \- (the hiphen) or \. (the dot).

Other special characters are:

” ^ [ $ ( ) | * + ? { \ ” .

A quick example:


<?php

$str = 'It\'s a nice day today.';
echo $str;

?>
  • Share/Bookmark
    

This post was written by:

Barry Bourland - who has written 43 posts on Mac Lab: An Apple Macintosh OS X & Mac / PC Blog.


1 Comments For This Post

  1. passer Says:

    hi
    you said dots need to be escaped, too
    but you didn’t escape it in your example

Leave a Reply