In my last post title “Crimson Editor With PHP”, I wrote about how to setup the Crimson Editor so that it will parse PHP and display the results to the output window. In this post I’m going to show how to setup Scite to parse PHP and display the results in the output window.
I’m sorry to disappoint you but this one will also be quite easy. Begin by opening Scite and under the options menu select Open html.properties Scroll all the way to the bottom of the file and look for:
if PLAT_WIN
command.go.$(file.patterns.web)=”file://$(FilePath)”
command.go.subsystem.$(file.patterns.web)=2
command.go.$(file.patterns.php)=c:\wamp\php\php.exe -q $(FileNameExt)
command.build.$(file.patterns.php)=c:\wamp\php\php.exe -l $(FileNameExt)
If you look at the code above you will see the path to the PHP interpreter which happens to be already changed in this code. The only difference between the code above and the default code is the path to the php interpreter. So simply look for the code above, change the bold text to the path of the php.exe interpreter on your local computers and save the file.
Note: I was running into problems with the code that follows the above code and a simply solution was to comment it out as follows:
if PLAT_GTK
#command.go.$(file.patterns.web)=netscape “file://$(FilePath)”
#command.go.$(file.patterns.php)=php -f “$(FileNameExt)”
#command.compile.$(file.patterns.php)=php -l “$(FileNameExt)”
I searched the web and couldn’t find anywhere that gave instructions on how to use the output windows in Crimson Editor to display PHP output. So that’s what I’m going to do in this post.This is going to be really simple so I hope you’re not expecting anything really hard.
I’m assuming you already have PHP and Crimson Editor installed on your local computer. The first thing you need to do is open Crimson and then open Tools > Conf. User Tools… from the menu at the top. Once you click Conf. User Tools… you will see the following Window.
All need to do is select an Empty slot from the list at the top center and fill in the fields below. I have a list of the fields you need to fill in and an explanation of what you need to put in each one.
- Menu Text - This is the name of the tool that will appear in the menu for you to select. Choose any name you want.
- Command - This is where you put the full directory path to the PHP interpreter or php.exe. On my machine it’s at c:\wamp\php\php.exe.
- Argument - This field is for the argument you want to pass to the program. Because we want the PHP program or interpreter to execute the file we’re working on we will send it the full path to the current file. For this we use $(FilePath) which happens to be a variable that inserts whatever file you’re currently working on.
- Finally make sure you check the box that says Capture output because this is what allows you to see the output in the output window. Crimson runs your code from the command line and captures everything in the window and pastes it in it’s own window.
It’s important to keep in mind that this will only parse the PHP code and not HTML. In other words you will see all the HTML without PHP code. You will see exactly the same thing as if you clicked view source on a web page.
In any language, a variable is essential to working with data and PHP is no different. If you have never done any programming you may be wondering what is a variable. Well, I’m going to explain that thoroughly here. If you’ve only worked with languages like PHP then this may still contain good information.
A variable is a name created for humans to work with and represent data stored in memory. When you want to work with data such as a name, it has to be stored somewhere and that happens to be the computer’s memory. Each memory address represents 1 byte but different data types such as an integer can take up more than 1 byte and therefore more than one address. For example, an integer usually takes up 4 bytes. It could get complicated and messy trying to keep track of what addresses are connected with something like a persons name or age. Variables were created for humans to allow them to assign a value to a name and then after you assign something to a variable the programming language automatically stores that data in memory and keeps track of what addresses correspond to each variable name. So, if I say $name = zach; I’ve assigned the name zach to the variable name $name and in PHP it automatically knows what addresses each letter in zach is stored at, you only need to remember $name.
Take a look at this picture to see an illustration of what I’m talking about. Each letter in the name is stored at a memory address which is represented by M1, M2, M3, etc.. (Click for larger image)
.
In this example we have a variable called $name and it has a value of zach. All we have to do when working with this value is use $name and it’s the same as saying grab the data stored at memory addresses M1, M2, M3, and M4 which returns zach. So we can use $name in functions like strtoupper() to make them all capitals letters like this strtoupper($name) and it’s the same as if we said strtoupper(”zach”).
If you’re completely new to programming you may be wondering why we just don’t type zach instead of using a variable. The reason is because we don’t always know what the value will be ahead of time. An example of this might be a form where you ask your visitors to register for an account. The username would get sent in a variable from the form to your script in a variable like this $_POST[’username’] and then you would instruct the script to see if $_POST[’username’] is in the database of usernames