Jeśli jesteś właścicielem tej strony, możesz wyłączyć reklamę poniżej zmieniając pakiet na PRO lub VIP w panelu naszego hostingu już od 4zł!

Working Software Blog: Escaping single and double quotes for use with XPath queries in PHP

Working Software Blog: Escaping single and double quotes for use with XPath queries in PHP

On the Working Software blog there’s a new post showing a solution to a issue with escaping quotes in XPath queries that’s not just an issue in PHP.

I’ve been working with the Basecamp API to plugin our IRC bot that we use for time tracking and I’m astounded to learn that escaping single and/or double quotes for XPath queries in PHP does not have a well documented, best practices solution. In fact, it seems as though this is not peculiar to PHP. I took a look around and found this excellent article by “Kushal”: http://kushalm.com/the-perils-of-xpath-expressions-specifically-escaping-quotes.

He’s put together his own (PHP) solution to the problem – running the entire XPath query through a filtering method that splits it up, replaces the quote characters and combines it back down to a single string.

Source: http://www.phpdeveloper.org/news/16746

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Posted Sierpień 21st, 2011 in WEB and PHP Development.

Leave a response: