4 Replies - 343 Views - Last Post: 30 October 2015 - 05:27 PM Rate Topic: -----

#1 Silverfox  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 23-October 15

PHP Function Question (Beginner)

Posted 30 October 2015 - 03:14 PM

I am only in my first few weeks of learning PHP. I am a beginner to programming and trying to learn functions at the moment.
What I am trying to do is understand how arguments work by using the example of using an argument to link to an external CSS file. I don't think I am understanding the process correctly and would appreciate a nudge in the right direction.
Here is what I have tried. This function is just for the top half of an HTML page. The first argument for changing the title tag works fine. Its just the second argument. Thanks.

<?php
function top($title, $css) {
 
echo'<!DOCTYPE html>';
echo'<html>';
echo'   <head>' 
echo    $css;
echo'		<title>' . $title . '</title>';
echo'	</head>';
echo'	<body>';
}

top('Contact Me', 'main.css');
?>



Is This A Good Question/Topic? 0
  • +

Replies To: PHP Function Question (Beginner)

#2 andrewsw  Icon User is online

  • But the opposite, you said.
  • member icon

Reputation: 5524
  • View blog
  • Posts: 21,798
  • Joined: 12-December 12

Re: PHP Function Question (Beginner)

Posted 30 October 2015 - 03:15 PM

You are missing a semi-colon at the end of line 6.

Just posting 'main.css' in the HTML won't link to a stylesheet though, it would need to appear within a link tag.

This post has been edited by andrewsw: 30 October 2015 - 03:17 PM

Was This Post Helpful? 1
  • +
  • -

#3 Silverfox  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 23-October 15

Re: PHP Function Question (Beginner)

Posted 30 October 2015 - 03:19 PM

Thanks Andrew for pointing that out

Rob
Was This Post Helpful? 0
  • +
  • -

#4 astonecipher  Icon User is offline

  • Licensed PITA
  • member icon

Reputation: 1724
  • View blog
  • Posts: 7,086
  • Joined: 03-December 12

Re: PHP Function Question (Beginner)

Posted 30 October 2015 - 03:24 PM

That still won't link a stylesheet to a html page.
Was This Post Helpful? 0
  • +
  • -

#5 no2pencil  Icon User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6223
  • View blog
  • Posts: 29,812
  • Joined: 10-May 07

Re: PHP Function Question (Beginner)

Posted 30 October 2015 - 05:27 PM

View Postastonecipher, on 30 October 2015 - 06:24 PM, said:

That still won't link a stylesheet to a html page.

What, you can't just blindly tell a markup language some text & it knows that it's the name of a file & what it should do with it?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1