Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Date: Sat, 01 Jun 2013 12:42:44 +0200 From: Luuk User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 Newsgroups: comp.lang.php Subject: Re: can one make a php function or macro with arguments to generate HTML code? References: <129060de-f94d-4853-ab35-0246d9cc2e35@2g2000yqr.googlegroups.com> In-Reply-To: <129060de-f94d-4853-ab35-0246d9cc2e35@2g2000yqr.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 63 NNTP-Posting-Host: 2001:980:9089:1:8111:3d06:bb3a:3104 X-Trace: 1370083501 news.xs4all.nl 15937 [2001:980:9089:1:8111:3d06:bb3a:3104]:36505 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.php:9723 On 01-06-2013 12:21, steve nospam wrote: > I am newbie. I am writing HTML and find myself duplicating lots of > code, which is the same except for 1 or 2 names/items in it. > > I do not know how to make a function or macro that takes arguments in > HTML or CSS. Then I read that php is much more powerful and one should > code HTML pages in php. > > Here is an example of what I have, I am just asking for a hint or a > link on how to code this in php. > >
> >
> > The above block of HTML close is repeated many time. Each time, a > different "folder_name" is used. > So I end up copy/paste and edit this code many many times. > > It would be nice if I can define a function, and just pass it the > folder_name and it returns back this whole code. So the above becomes > >
> make_video_code("ABC") >
> >
> make_video_code("ADR") >
> >
> make_video_code("ACB") >
> > etc.... you get the idea. > > Is something like this possible? Does any one have a templates or > example of how to do this in php? where to put the function > make_video_code()? > > thanks > Steve > I would also include the 'div' inside the function, like this (untested): function make_video_code($class, $video) { echo "
"; echo ""; echo "
"; } makevideo("name", "ABC"); makevideo("name", "ADR"); makevideo("different_class", "ACB");