1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

what is the need of PHP in a website?

Discussion in 'HTML & Website Design' started by georgiosr, Oct 8, 2007.

  1. #1
    Can someone clear this out for me please? We are looking for someone to redesign our website and everyone os asking me if i would like php into it?
    I currently use dreamweaver for any updates to text etc..
    Why would i need php? from the suggestions of the future designers it seems that with php i will update the content more easily etc.. can you please clear this out for me?

    Many thanks
     
    georgiosr, Oct 8, 2007 IP
  2. lbalance

    lbalance Peon

    Messages:
    381
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    database connectivity
    dynamic pages
     
    lbalance, Oct 8, 2007 IP
  3. GMROCKS

    GMROCKS Active Member

    Messages:
    648
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    60
    #3
    you won't have to upload everything, you'll be able to change things online through an admin area.
     
    GMROCKS, Oct 8, 2007 IP
  4. shahcloud

    shahcloud Peon

    Messages:
    95
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    HTML is strictly basic, which means no interactivity between the user and the site. User cannot make post or something like that.
     
    shahcloud, Oct 8, 2007 IP
  5. longhornfreak

    longhornfreak Well-Known Member

    Messages:
    2,067
    Likes Received:
    95
    Best Answers:
    0
    Trophy Points:
    140
    #5
    Php is what puts the functions into your site, html is just the look basically. They are basically adding a basic CMS into your site for easier use
     
    longhornfreak, Oct 8, 2007 IP
  6. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #6
    Wow... lots of misunderstanding in here.

    PHP is a server side scripting language that allows one to make a web page easier to maintain and more versatile. That's about it.

    You do not have to use a database to even make use of it, though it does have connectivity to a database. It is just a programming language from which you can output HTML.

    If you are just starting out with PHP, the first thing I suggest you learn is making a "poor man's" CMS - which is pretty much just using php in a manner much akin to SHTML.

    For example - all web pages on a site usually share a lot of elements in common. Header, Footer, menu, etc. As such, you can take JUST those parts, put them into one file each, then 'include' them from each page.

    For example (this is taken from one of my personal sites I'm rewriting right now - probably not going live for a month or so):

    header.php.inc - header and menu
    <?php
    echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    
    <script type="text/javascript" src="scripts/library.js"></script>
    
    <title>',$site_title,' - ',$page_title,'</title>
    
    <link href="screen.css" rel="stylesheet" type="text/css" media="screen,projection" />
    
    </head><body>
    
    <div id="container">
    	
    	<h1>',$site_title,'<span></span></h1>
    	
    	<div class="border_left">
    		<div class="border_right">
    			
    			<div id="main_menu"><div><div>
    				<ul>
    					<li class="current"><a href="index.php">Home<span></span></a></li>
    					<li><a href="factions.php">Factions<span></span></a></li>
    					<li><a href="minis_and_designs.php">Miniatures &amp; Designs<span></span></a></li>
    					<li><a href="software.php">Software<span></span></a></li>
    					<li><a href="news.php">News Archive &amp; Links<span></span></a></li>
    				</ul>
    			</div></div></div>
    			
    			<div id="inside" class="',$page_title,'">
    ';
    ?>
    Code (markup):
    footer.php.inc
    
    			</div>
    	
    			<table id="footer">
    				<tr>
    					<td class="company1">
    						<a href="#">Catalyst Game Labs<span></span></a>
    						Site Design by Jason M. Knight September 2007
    					</td><td class="disclaimer">
    						<p>
    							WizKids LLC has sole ownership of the names, logo, artwork, marks, 
    							photographs, sounds, audio, video and/or any proprietary material used
    							in connection with the game of
    							<a href="http://www.classicbattletech.com">Classic BattleTech</a>.
    							WizKids, LLC has granted permission to Deathshadow´s Battletech Page
    							to use such materials for promotional and informational purposes on
    							its website but does not endorse and is not affiliated with this 
    							website in any official capacity.	
    						</p>
    					</td><td class="company2">
    						<a href="#">WizKids<span></span></a>
    						Best viewed at 800x600 or higher with Mk.1 Rev.0 Sensors.
    					</td>
    				</tr>
    			</table>
    
    		</div>
    	</div>
    			
    	<div class="bottom">
    		<div></div>
    		<span>
    			Classic Battletech is currently under	license to 
    			<a href="#">Catalyst Game Labs.</a>
    		</span>
    	</div>
    		
    </div>
    </body></html>
    Code (markup):
    and then your normal page would read something like:
    <?php
    include_once('setup.php');
    
    $page_title='Home';
    
    include('includes/header.php.inc');
    
    echo '
    
    Your Page content goes here.
    
    ';
    
    include('includes/footer.php.inc');
    
    ?>
    
    Code (markup):
    As you can see, up top I include the header, and at the bottom I include the footer.

    The setup.php that is included sets up some global variables (like $page_title), and also includes my function library (/sources/common.php is what I call mine)

    The idea is that since the header for all pages is stored in just one file, to edit the menu on all pages one only needs to change - that's right, that one file.

    It is a full fledged programming language, so more complex things like news can be automated so you only have to edit the news item without the rest of the page being in the way. The news for this site doesn't even resort to a database - it simply stores each news item in a separate file in one directory, the filename starting with YYYYMMDD for the date followed by the title, username, with an extension article.txt with underlines as the delimiter - for example: "20070929_Redesign in Progress_deathshadow.article.txt" - My news function reads the file directory into an array sorted by name (which since the filename starts with the date...), figures out which ones we want shown off that array, then splits the filename into it's parts, reads in the files and spits them out in the middle of the page all nice and formatted.

    function news($mode,$start,$count) {
    global $article_dir,$users,$txt_convert;
    
    	$articles=scandir($article_dir,1);
    	$t=$start; 
    	$end=$t+$count;
    	if ($end>count($articles)) { $end=count($articles); }
    	while ($t<$end) {
    		switch ($articles[$t])	{
    	
    			case '.':
    			case '..':
    			break;
    	
    			default:
    				list($date,$subject,$author)=explode('_',$articles[$t]);
    				$author=$users[str_replace('.article.txt','',$author)];
    				$date=date("d F Y",
    					mktime(0,0,0,
    						substr($date,4,2),
    						substr($date,6,2),
    						substr($date,0,4)
    					)
    				);
    				$contents=str_ireplace($txt_convert['in'],$txt_convert['out'],
    					trim(file_get_contents($article_dir.'/'.$articles[$t]))
    				);
    				
    				switch ($mode) {
    					case 'accordion':
    						$target_id='news_'.$t;
    						echo '
    							<div id="',$target_id,'" class="article',(($t==$start) ? ' show' : ''),'">
    								<h3>
    						';
    						write_safejs('<a href="javascript:void(0);" title="Shrink/Expand News Item"  class="expander" onclick="javascript:toggleClassInID(\''.$target_id.'\',\'show\',this);"><b></b>');
    					break;
    					default:
    						echo '
    							<div class="article show">
    								<h3>
    						';
    					break;
    				}
    				echo '
    									',$subject,'<span>',$date,'</span>';
    
    				if ($mode=='accordion') write_safejs('</a>');
    
    				echo '
    								</h3>
    				';
    				write_safejs('<div class="article_body">');
    				echo '
    									<p>',$contents,'</p>
    									<div class="author">',$author,'</div>
    				';
    				write_safejs('</div>');
    				echo '
    							</div>
    				';
    			break;
    		}
    		$t++;
    	}
    }
    
    Code (markup):
    That means when I want to make a new news item, rather than playing with a database online or having to dig through my code and play with setting up a header, I can just make a flat .txt - carefully name it, upload it and done.

    Of course, this is a great example of why waste a database on something the filesystem itself can provide faster? (mind you, a database would allow fulltext searches and other sorting methods, but for this task I don't NEED that)

    PHP and other SSI languages remove a lot of the headaches from maintaining a site, but take a good deal of knowledge to write in the first place. I highly recommend it for any site you plan on updating regularly.
     
    deathshadow, Oct 8, 2007 IP
    Gregcyber likes this.
  7. Nora

    Nora Well-Known Member

    Messages:
    2,105
    Likes Received:
    76
    Best Answers:
    0
    Trophy Points:
    140
    #7
    I like having all my pages in php even if I don't have dynamic content. Nothing is more useful than being able to import headers/footers and different parts of the site so you don't have to copy it over and over again. :)
     
    Nora, Oct 8, 2007 IP
  8. Nythe

    Nythe Peon

    Messages:
    30
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    PHP is a very useful tool to have in a website. For one thing, as Nora states, it greatly reduces redundancy and unnecessary duplication of code which also makes it easier to maintain if you want to make even small changes to headers and footers.
    Furthermore, as people have posted previously, PHP allows for your website to display dynamic and user-specified data and also allows for certain functions like file uploads, form submissions and account registrations to be made possible.
     
    Nythe, Nov 1, 2010 IP
  9. jamadophotography

    jamadophotography Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    If you are familiar with InDesign then you should think of php as a master page. Let's say you create a "mater page" for your footer and you need to change the phone number. Instead of changing it on every page, you will just go to the footer "master page" and change it once so it's applied everywhere.
     
    jamadophotography, Dec 25, 2012 IP
  10. techbrain

    techbrain Greenhorn

    Messages:
    74
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    8
    #10
    If you are looking for some dynamic feature in your website then you need PHP, PHP is open source and server side scripting language used for dynamic website development.
     
    techbrain, Dec 26, 2012 IP
  11. infoway111

    infoway111 Member

    Messages:
    138
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    46
    #11
    Now a day, when we talk about web designing, the first language which comes into our mind is PHP. It is one on the hottest scripting language into today's technology world. Well, the reason behind its popularity is no license cost. PHP is an open source, which you can download free of cost and customize it according your project requirements. It comes with PHPMyAdmin, which is supported by database languages like MY SQL2.0, SQL, etc to create database tables.
    By using PHP, you can build fast, secure and dynamic web portals, as it is the most compatible language. The design and interface is very simple, which makes this language easy to understand. To make you application secure from virus and spyware attacks, the security functions are available with the technical support available worldwide.
    PHP is widely acclaimed open source programming language which has changed the web development scenario. It requires less processor space, so it doesn't affect the speed of the system. There are certain aspects like scalability, flexibility, usability which comes into our mind while creating a dynamic website. PHP is user friendly covering all these aspects mentioned above and makes it the most suitable language for creating web pages.
    The modular structure of codes in PHP can adapt the change and custom module can be created very easily. Ready to use framework like Zend can be used to build big web portals. Other frameworks like Joomla and Drupal are commonly used to develop business websites. Your blog system can be enhanced through WordPress Plugins.
     
    infoway111, Feb 7, 2013 IP