PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
wallabee
Forum Newbie
Posts: 20 Joined: Mon Apr 21, 2003 10:01 pm
Post
by wallabee » Fri Apr 25, 2003 8:18 pm
is this possible? for instance:
Code: Select all
print("<textarea name="textarea$file" cols="40" rows="8">FillTextArea()</textarea>");
FillTextArea takes the text from a text file and simply fills the text area with said text (and suddenly my two recent posts seem to connect).
-ben
m3mn0n
PHP Evangelist
Posts: 3548 Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada
Post
by m3mn0n » Fri Apr 25, 2003 8:37 pm
did you run it yet?
wallabee
Forum Newbie
Posts: 20 Joined: Mon Apr 21, 2003 10:01 pm
Post
by wallabee » Fri Apr 25, 2003 8:43 pm
it just puts, verbose, the words FillTextArea() in the text area.
m3mn0n
PHP Evangelist
Posts: 3548 Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada
Post
by m3mn0n » Fri Apr 25, 2003 8:47 pm
hmm..
Last edited by
m3mn0n on Sat Apr 26, 2003 10:48 am, edited 1 time in total.
airo
Forum Commoner
Posts: 31 Joined: Thu Apr 24, 2003 4:07 pm
Post
by airo » Fri Apr 25, 2003 10:05 pm
or split t up into three echos. Techniquelly there is a way to do it in one line, but it gets alittle messy that way, and i prefer to split it up into 3 echos.
phice
Moderator
Posts: 1416 Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:
Post
by phice » Fri Apr 25, 2003 10:11 pm
Code: Select all
<?php
function your_function() {
$string = "your displayed text";
return $string;
}
echo "Our function returns: " . your_function . "<br /><br />\n";
?>
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Sat Apr 26, 2003 5:27 am
Slight alteration to Phice's code (don't forget the parenthesis on the function name):
Code: Select all
echo "Our function returns: " . your_function() . "<br /><br />\n";
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Sat Apr 26, 2003 5:31 am
wallebee - with your code you can do:
Code: Select all
print '<textarea name="textarea'.$file.'" cols="40" rows="8">'.FillTextArea().'</textarea>';
or, if you want double quotes around it
Code: Select all
print "<textarea name="textarea$file" cols="40" rows="8">".FillTextArea()."</textarea>";
Not a big fan of escaping attribute quotes myself but some people don't like having to concenate in their variables... General principle is the same though - you have to leave the string to run the function and then return to it after to add the rest of it.
Mac
[]InTeR[]
Forum Regular
Posts: 416 Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands
Post
by []InTeR[] » Sat Apr 26, 2003 7:03 am
I'm a old C programmer, so correct all the programmers i'm working with to use quotes as they sould.
The ' is for char's. Not for strings.
The " is for strings.
And if a user has something like
i correct it to
Just make it more readable and understeadable for the progammer and the program.
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Sat Apr 26, 2003 7:15 am
But in PHP, stuff in single quotes isn't parsed so this:
would make more sense than
in that you wouldn't be making unecessary work for the parser.
Mac
[]InTeR[]
Forum Regular
Posts: 416 Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands
Post
by []InTeR[] » Sat Apr 26, 2003 7:18 am
There is a differents?
So your say'ing that the ' things are faster to compile for php then " ?
Learned something, and that in the weekeind
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Sat Apr 26, 2003 7:36 am
[]InTeR[] wrote: There is a differents?
Yup, check out:
http://uk.php.net/manual/en/language.types.string.php
[]InTeR[] wrote: So your say'ing that the ' things are faster to compile for php then " ?
probably won't make too much of a difference in small scripts but is more efficient.
Mac
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Sat Apr 26, 2003 9:00 am
and since today's topic if efficiency:
doesn't even waste time and memory for string concatenations.
btw:
<smartass>
it's not that much about compile but runtime efficiency.the substitution takes place the moment the statement is executed. </smartass>
airo
Forum Commoner
Posts: 31 Joined: Thu Apr 24, 2003 4:07 pm
Post
by airo » Sat Apr 26, 2003 10:43 am
I never knew there was a diffrence between ' and "... thanks mac!