Combining two PHP Functions
Posted: Sat Jun 30, 2007 1:55 pm
I currently have two php functions with the parameters $id, $title, $url, and $description. The parameters $id and $title are common to both function and ideally would be the same values in each function.
These two functions I call in the body of my web page like so:
What I would like to do is somehow combine both functions together so I could make one call and insert my parameters and it would output the html in the same format as above, i.e:
I would very much appreciate it if anyone could offer their assistance...maybe it's a bit of a newbie question but it would really help me to know how I could achieve this.
Code: Select all
<?php function myToolbarButtons($id,$title,$url,$description) { ?>
<a id="<?=$id?>" href="<?=$url?>" title="<?=$description?>"><?=$title?></a>
<?php } ?>
<?php function myToolbarContent($id,$title) { ?>
<div id="<?=$id?>-section">
<h2><?=$title?></h2>
</div>
<?php } ?>Code: Select all
<div id="buttons">
<?php myToolbarButtons(about,About,http://www.asite.com/about/index.php,About this site);?>
<?php myToolbarButtons(contact,Contact,http://www.asite.com/contact/index.php,Drop us a line);?>
<?php myToolbarButtons(comment,Comment,http://www.asite.com/comment/index.php,Voice your opinion);?>
</div>
and.....
<div>
<?php myToolbar(about,About);?>
<?php myToolbar(contact,Contact);?>
<?php myToolbar(about,Contact);?>
</div>Code: Select all
<?php myNewToolbar(about,About,http://www.asite.com/about/index.php,About this site);?>
<?php myNewToolbar(contact,Contact,http://www.asite.com/contact/index.php,Drop us a line);?>