Solution for highlighting PHP variables in strings

Post your questions and problem reports here

Moderator: kfury77

Forum rules
Please try to follow these guidelines. This will help to receive faster and more accurate response.
  • Check the Support section of the corresponding product first. Chances are you will find your answer there;
  • Do not create new topics for already reported problems. Add your comments to the existing topics instead;
  • Create separate topic for each problem request. Do NOT post a number of non-related problem reports in a single topic;
  • Give your topic a meaningful title. Titles such as "A question," "Bug report" and "Help!" provide others no clue what your message is about;
  • Include the version number of the software you are using;
  • This is not an official customer support helpdesk. If you need a prompt and official response, please contact our support team directly instead. It may take a while until you receive a reply in the forum;
Post Reply
User avatar
Karlis
Site Admin
Posts: 3605
Joined: Mon Jul 15, 2002 5:24 pm
Location: Riga, Latvia, Europe
Contact:

Solution for highlighting PHP variables in strings

Post by Karlis »

For advanced geeks only, requires some script editing :)

Here's how:

1) Options -> preferences -> Text Editor -> Colors -> Advanced -> Custom Scripts
2) Save original HTML with PHP script
3) Browse it for Highlighter Script File
4) Edit the script

After this line: State=sphpvar
Add this line:
State=sphpvar2

After this line: sphpstring2 \\[^\\] sphpstring2 tphpstring
Add these lines:
sphpstring2 \$ sphpvar2 tphpvar
sphpvar2 [a-z_A-Z][a-z_A-Z0-9]* sphpstring2 tphpvar

5) Restart WeBuilder/Rapid PHP

This should do until we come with a better solution. I think it would be better to highlight variables inside strings with a differrent color.
Karlis Blumentals
Blumentals Software
www.blumentals.net
User avatar
syrupcore
Top Contributor
Posts: 917
Joined: Thu Jul 21, 2005 12:58 am
Location: Portland, Oregon, usa
Contact:

Post by syrupcore »

hey, that's cool.
D@ve
Posts: 7
Joined: Sat Dec 16, 2006 3:45 pm
Contact:

Post by D@ve »

Hmmmm... doesn't work

Regards, Dave
User avatar
chrisjlocke
Top Contributor
Posts: 995
Joined: Mon Aug 01, 2005 4:12 pm
Location: Essex, UK
Contact:

Post by chrisjlocke »

Can you provide some more info - "doesn't work" in what way?
What version of what application are you using?
D@ve
Posts: 7
Joined: Sat Dec 16, 2006 3:45 pm
Contact:

Post by D@ve »

Sorry - Rapid PHP 2007 8.3.1.81

Hmmm in what way... Good question... PHP-Variables aren't highlighted in strings....

Here's my Highlight-File
http://www.2jesus.de/files/dave/test.xs

thanks a lot
Dave
Gatis
Blumentals Software Developer
Posts: 545
Joined: Sun Mar 05, 2006 12:30 am
Location: Latvia

Re: Solution for highlighting PHP variables in strings

Post by Gatis »

Hi,

Just to inform everybody.
There is a syntax highlighter file named PHPwithVarsInStrings.xs shipped with editor under folder C:\Program Files\WeBuilder 2010\data\hscripts
Use it instead of the default PHP highlighter script if you want to have PHP variables highlighted inside strings.
Kind regards,
Gatis Avots
User avatar
notuo
Posts: 258
Joined: Sat Jul 09, 2005 8:07 pm
Location: Tlalpan, Mexico City, Mexico

Re: Solution for highlighting PHP variables in strings

Post by notuo »

This is nice, Thanks.

I just tried and is working.

Just one thing: The highlight variables within the strings are highlighted in black (rapidphp) and the normal color is red.

Is this normal or do I have to change something.
User avatar
Karlis
Site Admin
Posts: 3605
Joined: Mon Jul 15, 2002 5:24 pm
Location: Riga, Latvia, Europe
Contact:

Re: Solution for highlighting PHP variables in strings

Post by Karlis »

You have to specify color for these separately then.
Karlis Blumentals
Blumentals Software
www.blumentals.net
russellweed
Posts: 24
Joined: Tue Aug 21, 2007 3:40 pm

Re: Solution for highlighting PHP variables in strings

Post by russellweed »

Awesome. Thanks for this!
jmurch
Posts: 9
Joined: Mon May 03, 2010 10:59 pm

Re: Solution for highlighting PHP variables in JS

Post by jmurch »

I found the custom script too works great..............

I have another similar issue which is highlighting PHP within JS doesn't work:

<script type="text/javascript">
$(document).ready(function(){
<?
if(!isset($_SESSION['auth']['server_status'])){
?>
$.ajax({
type: 'GET',
dataType: 'jsonp',
url: 'http://website.com/SAP_status.php',
success: function(data){
$.ajax({
type: 'POST',
url: '/login/login_logic.php',
data: 'action=server_status&result='+data['result_string'],
complete: function(output){
}
});
}
});
<?
}
?>

});
</script>
Post Reply