zero-perfoliate
zero-perfoliate

Author Topic: Questions about using php and css together  (Read 960 times)

Offline Fireater989

  • New PHP Members
  • Posts: 1
  • Karma: +0/-0
Questions about using php and css together
« on: November 29, 2009, 04:38:25 PM »
So, I am new to php and am planning a site with over 100 pages and want to be able to edit them easily. One question I had was, is php ONLY for html where I rename my html pages and includes to php? I was reading on LissaExplains.comhttp://lissaexplains.com/html6.shtml#SSI about SSI and PHP and it was saying how SSI could be used for javascript, html, etc, all you have to do is rename pages to .shtml. Now, I don't want to use SSI, but how would the browser know what was html, css, javascript... if the extension is .txt?
Another question I have is, how does css apply to php? Im using a template with the style already made, I plan on cutting some of the html and placing it in a .php. Would I need to apply the style inside my include, or is it fine in my main page, where it is pointing to an external sheet?
Also, there are no problems integrating css with php is there?
Thanks in advance for your help

hotnoob

  • Guest
Re: Questions about using php and css together
« Reply #1 on: December 06, 2009, 11:10:09 AM »
K... im just going to ignore ur post somewhat... and just explain how to use php to optimize your work time.

This is considered to be an industrial method used for professional programmers

Create 2 files....
lets call the first one top.php
Code: [Select]
//file::top.php
//include all of your top information, leading to your content. for example, <table><tr><td>

The next is bottom.php
Code: [Select]
//file::bottom.php
//include all of your ending structures and code. for example </td></tr></table>

Now... how to use this...
let's say its your index... // note php only loads on .php file extentions, unless you modify your php scripts, in which case you will probably need  to have your own server to do.
Code: [Select]

<?php include("top.php");?>
<!-- content -->
BLah blah blah, welcome to this site... blah blah blah
<?php include("bottom.php");?>

Another industrial method... but one i don't like because it has severe limitations is...
Code: [Select]
//file::template.php
//top design
<?php echo $content;?>
//bottom design
your index would be...

Code: [Select]
<?php 
$content 
"BLah blah blah, welcome to this site... blah blah blah";
include(
"template.php");
?>


Here is another method, this one is something newbies use.
Code: [Select]
//file::loadFunctions.php

function loadContent()
{
 echo "Content";
}
Code: [Select]
//file::index.php
<?php
include("loadFunctions.php");
loadContent();

?>



Offline heronfisher

  • New PHP Members
  • Posts: 4
  • Karma: +0/-0
Re: Questions about using php and css together
« Reply #2 on: March 12, 2010, 05:23:15 AM »

It is always best to put CSS into it own file.

Then at the header section of the main file use :

<link href="path to your css file.css" rel="stylesheet" type="text/css" media="screen" />

Also if you going to use Php. Then try to apply template to your programing.

Create 2 file call herder.php and footer.php that contain the header and footer part of your site (thing in header and footer that does not change alot from page to page). Then use include_once to include the header and footer into each php page.

Will save you a lot of time for building and maintenance.

hotnoob

  • Guest
Re: Questions about using php and css together
« Reply #3 on: March 15, 2010, 01:07:47 PM »

It is always best to put CSS into it own file.

Then at the header section of the main file use :

<link href="path to your css file.css" rel="stylesheet" type="text/css" media="screen" />

Also if you going to use Php. Then try to apply template to your programing.

Create 2 file call herder.php and footer.php that contain the header and footer part of your site (thing in header and footer that does not change alot from page to page). Then use include_once to include the header and footer into each php page.

Will save you a lot of time for building and maintenance.
External .css files can not contain php scripts tho.
So if you have extremely dynamic css like in my prototype
http://famousliving.isgreat.org
external css will not work, unless the server is configured correctly... but even then, the browser will cache it. So, if you are constantly changing the css, based on the users input, having a cached css file will not work well.

Offline RoseKnight

  • PHP Help Guru's
  • ****
  • Posts: 52
  • Karma: +0/-0
Re: Questions about using php and css together
« Reply #4 on: March 19, 2010, 07:12:33 PM »
Not to sound rude, but how much do you actually know about PHP, HTML, and CSS?

you kinda have to get a bit of knowledge on how each work individually before you start combining them. Then you experiment with each before starting on a 100 page project.

Secondly: What are you plans with combining the two? what are you trying to accomplish with your website, and what do you NEED to accomplish.

These are very important pieces of information you need to consider when beginning a new project.

hotnoob

  • Guest
Re: Questions about using php and css together
« Reply #5 on: March 23, 2010, 12:05:10 AM »
Not to sound rude, but how much do you actually know about PHP, HTML, and CSS?

you kinda have to get a bit of knowledge on how each work individually before you start combining them. Then you experiment with each before starting on a 100 page project.

Secondly: What are you plans with combining the two? what are you trying to accomplish with your website, and what do you NEED to accomplish.

These are very important pieces of information you need to consider when beginning a new project.

You'll never learn with this philosophy :P

If you don't challenge yourself, you'll never learn anything new :P
That is why i have prototype websites such as the one in my previous post.

:D

Well.. you can read textbooks and other junk, but personally, i fall asleep reading them... just 30 seconds staring at a textbook and I'm out like a lite :P

Offline RoseKnight

  • PHP Help Guru's
  • ****
  • Posts: 52
  • Karma: +0/-0
Re: Questions about using php and css together
« Reply #6 on: March 23, 2010, 03:37:16 PM »
Thats what the experimentation is for? you start with doing what you want with the one page, then add multiple pages to make sure your code still works. And then add more and make sure everything is working. And then you know it works. haha

Offline madison12

  • New PHP Members
  • Posts: 1
  • Karma: +0/-0
Re: Questions about using php and css together
« Reply #7 on: May 19, 2010, 10:20:53 PM »
hello hotnoob..........

Thank you for your valuable information.


web development services