Dann, Guru of PHP...
Moderators: snarkout, Patrick, dann
-
jelkimantis
- Posts: 24
- Joined: Wed Apr 30, 2008 9:19 pm
Dann, Guru of PHP...
So I'm working on a project, and each page has some formatting that needs done, just basic stuff like default text, basic formatting, etc.
I'm wondering what the best way to accomplish this might be. I'm thinking about building a default_html.php file that has the basics in it (divs, basic page layout, etc)... Inclusion of theme files and references to javascript files would be in this file... My idea is that I'll just call this page whenever I'm rendering a page, and it will set things up right, and whatever I'm passing back will be wrapped in a "content" div that will then put the content in the right place, depending on what it is.
Am I thinking right, or am I blatantly stupid?
I'm wondering what the best way to accomplish this might be. I'm thinking about building a default_html.php file that has the basics in it (divs, basic page layout, etc)... Inclusion of theme files and references to javascript files would be in this file... My idea is that I'll just call this page whenever I'm rendering a page, and it will set things up right, and whatever I'm passing back will be wrapped in a "content" div that will then put the content in the right place, depending on what it is.
Am I thinking right, or am I blatantly stupid?
Re: Dann, Guru of PHP...
Not at all stupid, this is the way to go. Seperate the presentation from the data. The simplest way to go about this is the create some files to cover the presentation in the head and body sections of a page. You may want to break down the body then to have separate header, navigation and footer. Then you can include those files into each page so if any changes are required you only have to make them in one place.
How complex you want to make this is up to you. But you are on the right track.
How complex you want to make this is up to you. But you are on the right track.
-
jelkimantis
- Posts: 24
- Joined: Wed Apr 30, 2008 9:19 pm
Re: Dann, Guru of PHP...
Ok! Awesome. Thanks for the help! I'm sure I'll be querying you more again soon. 
-
jelkimantis
- Posts: 24
- Joined: Wed Apr 30, 2008 9:19 pm
Re: Dann, Guru of PHP...
So, encore!
I've got a tidy bit of code that makes me happy, but there is a problem.
I'm pulling data from MySQL, parsing it in php, and returning it to the main page through an AJAX function. While this works swimmingly, somewhere along the line my carriage returns and quotation marks are being turned into:
�
I've stripped slashed, but I'm not sure what else I can do. Maybe a string replace for the quotes? make them " instead? but what do I do about the carriage returns? How do I screen for those?
jsl
I've got a tidy bit of code that makes me happy, but there is a problem.
I'm pulling data from MySQL, parsing it in php, and returning it to the main page through an AJAX function. While this works swimmingly, somewhere along the line my carriage returns and quotation marks are being turned into:
�
I've stripped slashed, but I'm not sure what else I can do. Maybe a string replace for the quotes? make them " instead? but what do I do about the carriage returns? How do I screen for those?
jsl
Re: Dann, Guru of PHP...
htmlspecialchars and nl2br maybe?
-
jelkimantis
- Posts: 24
- Joined: Wed Apr 30, 2008 9:19 pm
Re: Dann, Guru of PHP...
As noob as I am, tried the htmlspecialchars() and to no avail.dann wrote:htmlspecialchars and nl2br maybe?
I'm wondering if the quotes got encoded wrong in the db somehow... It *is* a copy of a db... maybe something when horribly wrong in the encoding.
jsl
-
jelkimantis
- Posts: 24
- Joined: Wed Apr 30, 2008 9:19 pm
Re: Dann, Guru of PHP...
Ok, so somehow the encoding got all futzed up. I went in and replaced all the <?> messed areas with the correct symbol and the htmlspecialchars() worked fine with those changes.
Oh well... C'est la vie!
jsl
Oh well... C'est la vie!
jsl