| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 30247 | 2003-02-14 03:17:00 | PHP: Joining Strings | InverseEight (1360) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 121106 | 2003-02-14 03:17:00 | Hello, Im just trying some things in php but they aren't working as expected. I have: $barext = "&bar=close" then directly after that is a function function genbutton($page_title,$page_link) { return "<various html code><a href=\"$page_link\"><more html>"; } And BELOW that the function is called to generate some buttons. I have tried so many things to get $barext to be added to $pagelink: <a href=\""&$page_link.$barext&"\">; <a href=\"".$page_link.$barext."\">; $page_link = $page_link.$barext; (on the line above) but nothing seems to work. Im assuming the $barext isn't usable from within the function? So I want to know the easiest way of going about this. Also I'm wondering how to join to variables that are in a string: ie <? echo "Hello my name is $firstname.$lastname, I am pleased to meet you"; ?> This leaves the dot there, and I'm guessing there is an easier way than closing the quotes to do it? (<? echo "Hello my name is "&$firstname&" "&$lastname&", I am pleased to meet you"; ?> or whatever ) All help appreciated, Thanks. |
InverseEight (1360) | ||
| 121107 | 2003-02-14 03:32:00 | Check out www.php.com and look for documentation. To add one string <$str1> to another <$str2> try this: $str3 = sprintf("%s %s",$str1,$str2); If $str1 = "Mike" and $str2 = "Jones" $str3 will now be "Mike Jones" The website above has a lot of documentation :-) |
penz (3104) | ||
| 121108 | 2003-02-14 04:19:00 | firstly, joining two strings together is as easy as '.' yes, a full stop, or the concatenation operator, eg <? $varone = 'foo'; $vartwo = 'bar'; $varthree = $varone . $vartwo; // $vartwo = 'foobar' ?> is there another prob? grtz sal. tga |
sal (67) | ||
| 121109 | 2003-02-14 04:22:00 | ok, i stuffed that up, append above $varthree='foobar' grtz sal. tga |
sal (67) | ||
| 121110 | 2003-02-14 09:38:00 | Well That's a darn site easier than my method. Thanks |
penz (3104) | ||
| 121111 | 2003-02-15 09:12:00 | Thanks for the help, but it's not really what I wanted I know how to join strings using a dot, but when they are in quotes, and right after each other, it doesnt work. Because the dot used to join the strings is considered part of the text. |
InverseEight (1360) | ||
| 121112 | 2003-02-15 09:37:00 | Add "."\" to open the quote and "\"". to close the quote like: echo "To quote Aristotle "."\" ".$quote."\""."\r\n; |
Merlin (503) | ||
| 121113 | 2003-02-17 13:33:00 | Hmm my PHP is rusty as lately I have been working with ASP. I believe if you do the right 'escape' data you can enter it after it <? $byebyefox="Before it got shot by the hunter"; $myvar="the quick brown fox jumped over the lazy dog \. $byebyefox \."; echo $myvar; ?> Now off the top of my head i cant recall if that is 100% accurate and i dont have PHP installed right at this minute so i would suggest testing it. |
Captive (3159) | ||
| 121114 | 2003-02-17 13:39:00 | <?php $xp="I love"; $dosforxp="I hate."; $sidenote="Thats why vmware is definitly worth considering"; echo "Microsoft Windows XP stability $xp\. But when i started trying to run legacy games like captive, the Dos support $dosforxp$sidenote" ?> hmm if you still cant do it let me know and i'll put on PHP again for IIS to test it out a bit.... I can do it tommorrow night after tech [assuming that you will have replied by then] |
Captive (3159) | ||
| 1 | |||||