PDA

View Full Version : Editing php template files



dynocat
10-06-2009, 11:22 AM
I hope this is simpler than I think.

I know how to edit html and css files. If I have a template.php file, is it as easy as "saving as" html, then after editing, "saving as" php?

billbenson
10-06-2009, 11:59 AM
If its a file in your template system, it probably is file.php. To edit it, open it in some text editor, make your changes, and you are done. Good idea to save a backup of the original as well. There is no need to save it as html.

Did that answer your question?

bacterozoid
10-06-2009, 12:20 PM
PHP, HTML, and CSS files are all simple text files with different extensions. When you save your PHP file, as long as you save it with a .php extension you will be fine.

Most likely your editor will take care of it for you. Just open the file, make your changes, then save it as you would any other file. There's no special process.

vangogh
10-06-2009, 03:59 PM
The extension is ultimately a signal to your sever how to interpret that file. Most servers are set to treat anything that ends in .html or .htm as an html file. They are set to treat things that end in .php as a php file so they know to first pass the file to the php parser before sending it to the browser.

Aside: This isn't really your question, but you can set your server to treat .html as php or .php as html. I hope that's not confusing things.

So yes, saving the file as template.php will mean it will be treated as a php file by your web server. And you don't need to save it as .html first. Of course just because a file ends in .php doesn't mean it will work. The extension only tells the web server how to deal with the file. Naturally your .php file needs to have actual working php code in it, though I assume it does.

dynocat
10-06-2009, 07:50 PM
Thanks, everyone.

I'm using WeBuilder from Blumentals for editing.

Opened a header file. The first line reads:

<?php print '<?xml version="1.0" encoding="' . $lang->getCharset() . '" ?>' ?>

When previewing, I get this error. WTHeck does it mean?

Fatal error: Call to a member function getCharset() on a non-object
Call Stack
# Time Memory Function Location
1 0.0027 85296 {main}( ) ..\header.tem.php:0

vangogh
10-06-2009, 09:35 PM
Are you previewing just the header file or the whole page?

You actually don't need that line of code for anything so you would be safe removing the whole thing.

getCharset() would be a function that's being called. The object that's causing the error is $lang. $lang would need to be instantiated as an object before the line of code you're showing is called.