473,378 Members | 1,592 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Making "containers" - is there a way?

I want to do this:

function square ($a){ print "-- $a --"; }

And use it like this:

<? square( ?> Hello! <? ) ?>

And get this:

-- Hello! --

But of course it doesn't work, so I have to do this:

function square1 { print "-- "; }
function square2 { print " --"; }

And us it like this:

<? square1() ?> Hello! <? square2() ?>
Which isn't as clean... Is there a way to solve it like I want to do it?
If you hadn't understood it yet, it's for making a frame around blocks
of text.
Jul 16 '05 #1
6 2011


it's for making a frame around blocks of text.


Not sure exactly what you meant, but have you considered doing this in CSS
stylesheets?
<style type="text/css">
p.box {border: 1px solid black; padding: 8px;}
</style>
<p class="box">Block of text</p>

Martin
Jul 16 '05 #2
Sandman wrote:
If you hadn't understood it yet, it's for making a frame around blocks
of text.


<p style="border-style: dashed; border-width: 1px; border-color:
black;">Hello</p>

HTH;
JOn
Jul 16 '05 #3
In article <Pi**************************************@green.cs i.cam.ac.uk>,
Martin Lucas-Smith <mv***@cam.ac.uk> wrote:
it's for making a frame around blocks of text.


Not sure exactly what you meant, but have you considered doing this in CSS
stylesheets?
<style type="text/css">
p.box {border: 1px solid black; padding: 8px;}
</style>
<p class="box">Block of text</p>


Thanks, but CSS only affects the appaerance, I want to actually insert things
before and after the text.

--
Sandman[.net]
Jul 16 '05 #4
In article <bi**********@titan.btinternet.com>, haptiK <no****@nospam.com>
wrote:
I want to do this:

function square ($a){ print "-- $a --"; }

And use it like this:

<? square( ?> Hello! <? ) ?>

And get this:

-- Hello! --

But of course it doesn't work, so I have to do this:

function square1 { print "-- "; }
function square2 { print " --"; }

And us it like this:

<? square1() ?> Hello! <? square2() ?>
Which isn't as clean... Is there a way to solve it like I want to do it?
If you hadn't understood it yet, it's for making a frame around blocks
of text.


whats wrong with the following...
<?php
function square($a) {

print "-- $a --";

}
?>

<?php square('Hello!'); ?>

thats all you need to do... am i missing something here?


Well, I want to use this for things like:

<? square( ?>
Hello, everything here will be inside a nice looking box, constructed with a
table, and this image will also look fine: <img ....> And bla bla bla...
<? ); ?>

See? I don't want to be restricted by the limitations that the function string
implies.

--
Sandman[.net]
Jul 16 '05 #5
Sandman:
Well, I want to use this for things like:

<? square( ?>
Hello, everything here will be inside a nice looking box, constructed with
a table, and this image will also look fine: <img ....> And bla bla bla...
<? ); ?>

See? I don't want to be restricted by the limitations that the function
string implies.


Use a function, but whenever the string becomes complicated use heredoc
syntax (see
http://www.php.net/manual/en/languag...syntax.heredoc)

If the contents become quite large, use file inclusion where
square('filename') means to wrap the contents of filename with whatever you
define in square().

IMO they are both a lot easier on the eye than the syntax you want... Don't
forget that other people may have to work with your code at some stage :)

André Nęss
Jul 16 '05 #6

"Sandman" <mr@sandman.net> wrote in message
news:mr**********************@news.fu-berlin.de...
Well, I want to use this for things like:

<? square( ?>
Hello, everything here will be inside a nice looking box, constructed with a table, and this image will also look fine: <img ....> And bla bla bla...
<? ); ?>

See? I don't want to be restricted by the limitations that the function string implies.


How about doing it the template way ? Just insert an imaginary tag to your
HTML, like {square}:

{square}
Hello, everything here will be inside a nice looking box, constructed with a
table, and this image will also look fine: <img ....> And bla bla bla...
{/square}

Then at the end just pass all the output of the file through a function that
replaces {square} and {/square} with whatever you wish. output buffering
will be handy here, lets you edit and play with outputted text (text outside
php tags) before it is sent to the browser.
See: http://www.php.net/ob_start
HTH

--
Suni
Jul 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

87
by: ziliath | last post by:
I recently tried out the Google "top coder" contest, as a C++ coder. I noticed immediately that they expected me to know STL. To which I say, what the fuck?! I may be missing something, but at...
16
by: recover | last post by:
#include <string> #include <iostream> using namespace std; class TConst { private: string con; string uncon; public:
48
by: Tony | last post by:
How much bloat does the STL produce? Is it a good design wrt code bloat? Do implementations vary much? Tony
169
by: JohnQ | last post by:
(The "C++ Grammer" thread in comp.lang.c++.moderated prompted this post). It would be more than a little bit nice if C++ was much "cleaner" (less complex) so that it wasn't a major world wide...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.