View Full Version : PHP rules
slarti42uk
21-Jan-2004, 04:07 AM
Hi,
I've set up some simple rules for use with PHP scripts but I've run into a small problem. I added a rule: Text from // to end of line. This is for excluding comments, however I need to overide this when the // apears as part of a URL. With the setings I now have differences in URL are ignored.
I have read a few other posts regarding using the string literals with reg expressions but I'm not sure what this would hve to be for my purpose.
The rule I need is:
Ignore lines from // but not when the text http: apears in front of it. :confused:
Thanks in advance for any help.
[Edit]
I worked it out from some online reg exp stuff, cheers.
The answer was to put http://.* in as a reg exp in the string literals box.
How are your PHP rules working out? If you would like us to post them on our Additional Rules (http://www.scootersoftware.com/download.php?c=kb_morerules) page, you can export them from BC (Tools | Export) and email the file to us. :)
how would I go about doing this as I need to do this as well and of course in the comments there is a time created field and a version number but of course these will be different to my original files so every script is showing as different.
thought id better post an example of the code i wish to bypass
<?php
/*================================================= =====================*\
|| ################################################## ################## ||
|| # vBulletin 3.0.1 - Licence Number private
|| # ---------------------------------------------------------------- # ||
|| # Copyright ©2000–2004 Jelsoft Enterprises Ltd. All Rights Reserved. ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
|| ################################################## ################## ||
\*================================================ ======================*/
Chris
16-Apr-2004, 09:57 AM
To ignore php comments such as /* to */, //, and #
Create a new rule, associated with *.php
Go to the Importance Tab.
Under the Unimportant Text section click new.
To ignore mult-line comments, from /* to */
Pick the Delimited category.
Beginning with: /*
ending with: */
For a single line comment, //
create a new unimportant text entry
Pick Delimited.
Beginning with: //
check the stopping at end of line check box.
Repeat for # comments.
This should ignore differences in any php comments.
Also refer to the first post:
The answer was to put http://.* in as a reg exp in the string literals box.
To make sure the earlier // comments don't comment out urls.
The answer was to put http://.* in as a reg exp in the string literals box.
To make sure the earlier // comments don't comment out urls.
I went with http://[^\s]+ so it would match 1..N non-whitespace characters. If you wanted to be really persnickity you could check the RFCs and only list the acceptable characters...
mdrmike
12-Feb-2006, 04:39 PM
Why isn't this a default rule in bc? ...I mean this thread is a couple of years old. php is popular to say the least. I think it would be nice for new users of bc to not have to hunt
Chris
13-Feb-2006, 04:57 PM
PHP rules can be challenging because PHP files can mix HTML and PHP. If the entire file is PHP, setting up a rule isn't hard, but if you have mostly HTML with a little PHP throughout, the current version of BC can't use different settings within the <?php to ?> tags.
We are considering having a default PHP rule in a future version of BC.
vBulletin® v3.7.1, Copyright ©2000-2010, Jelsoft Enterprises Ltd.