You are here

Monthly archive

PHP Regular Expressions – Remove Comments From SQL Text

This short block of PHP code takes a SQL script and removes the “dash-dash” and “/**/” comments from it.  Of course, many languages, including PHP itself, use the “/**/” comment style so this could apply to PHP scripts, as well.

The line that removes the dash-dash style comments could easily be changed to the “//” (slash-slash) style.

Notice the use of percent-signs as delimiters to eliminate the need of escaping forward-slashes.

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
1 + 0 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer