473,795 Members | 2,980 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

trying to combine a print stmt

Thanks ahead for your help

I'm trying to learn what I can do with echo and print statements. I
figured out the echo statement and below is the simple version using
print. I've tried two dozen or more single print statements, first
start with the first part then adding additional phrases, then looking
at the page source code, but I'm missing something simple,(isn't that
always the way) What I'm trying to understand is how, if it's possible,
to combine the three statements into one print statement. If this
isn't possible will printf work?

print("<a href=\"login.ph p?");
print(session_i d());
print("&whichpa ge=$i\">login link $i</a>");

Thanks
Mike

Jul 17 '05 #1
3 2273
"mmccaws" <mm*****@netsca pe.net> wrote in news:1109734363 .485993.172740
@g14g2000cwa.go oglegroups.com:
Thanks ahead for your help

I'm trying to learn what I can do with echo and print statements. I
figured out the echo statement and below is the simple version using
print. I've tried two dozen or more single print statements, first
start with the first part then adding additional phrases, then looking
at the page source code, but I'm missing something simple,(isn't that
always the way) What I'm trying to understand is how, if it's possible,
to combine the three statements into one print statement. If this
isn't possible will printf work?

print("<a href=\"login.ph p?");
print(session_i d());
print("&whichpa ge=$i\">login link $i</a>");


Yes, you can combine print statements using the concatenation operator (the
period). For example,

print '<a href="login.php ?' . session_id() . "&whichpage=$i\ ">login link $i
</a>";

Basically, you just take the items you're printing on each individual print
statement, and string them all together with periods on a single line.
Another tip from the code above, in the first section of the print
statement. If you're printing out a string that contains question marks but
no variables and no single-quotes, you can surround the string in single-
quotes and avoid the need to escape the quotation mark.

hth

--

Bulworth : PHP/MySQL/Unix | Email : str_rot13('f@fu ng.arg');
--------------------------|---------------------------------
<http://www.phplabs.com/> | PHP scripts, webmaster resources
Jul 17 '05 #2
NC
mmccaws wrote:

how, if it's possible, to combine the three statements
into one print statement.

print("<a href=\"login.ph p?");
print(session_i d());
print("&whichpa ge=$i\">login link $i</a>");


Here are some options:

1. Use concatenation operator:

print "<a href=\"login.ph p?" . session_id() .
"&whichpage=$i\ ">login link $i</a>";

2. List multiple arguments (won't work with print though,
only with echo):

echo "<a href=\"login.ph p?", session_id(),
"&whichpage=$i\ ">login link $i</a>";

3. Combine multiple strings into one before output:

$sid = session_id();
print "<a href=\"login.ph p?$sid&whichpag e=$i\">login link $i</a>";

Cheers,
NC

Jul 17 '05 #3
.oO(mmccaws)
print("<a href=\"login.ph p?");
HTML also allows single quotes around attribute values.
print("&whichpa ge=$i\">login link $i</a>");

^
This has to be &amp; in order to be valid HTML.

Micha
Jul 17 '05 #4

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

Similar topics

1
1758
by: Art | last post by:
Hello, I can't seem to get eval or compile to accept the print stmt, or any complicated statements. The documentation I've looked out doesn't explain why this is. ex: >>> eval("print('foo')") Traceback (most recent call last):
2
3854
by: claus.hirth | last post by:
I wrote a stored procedure that uses a prepared INSERT INTO statement in order to play with the PREPARE and EXECUTE keywords. In transcript 1 below the call to that stored procedure does not work. Yet transcript 2 shows that the stored procedure does its job, if only the table name is provided directly in the statement text string, instead of as a host variable to a prepared statement like in 'EXECUTE stmt USING tabName, fldValue'. --...
24
8180
by: trint | last post by:
add them into one PrintDocument: PrintDocument pd1 = new PrintDocument(); PrintDocument pd2 = new PrintDocument(); PrintDocument pdCombined = new PrintDocument(); pdCombined = pd1 + pd2; pdCombined.Print(); Thanks, Trint
1
3009
by: Uzytkownik | last post by:
I've some function: function show($id) { $title = $text = $date = $nick = NULL; $stmt = $this->base->stmt_init(); $stmt->prepare("SELECT title,text,datetime,nick FROM posts LEFT JOIN authors ON authors.id=posts.id WHERE posts.id=?"); $stmt->bind_param('i', $id); $stmt->bind_result($title, $text, $date, $nick); $stmt->execute(); $stmt->fetch(); return array('title'=>$title, 'text'=>$text, 'date'=>$date, 'author'=>$nick, 'tags' =>...
1
2326
by: Steff | last post by:
I am wandering if my code is making sense... I use a lot the print function. Is it weird in this case where I have to display an array ? I thought it would be better to have the entire array in php but now I am not sure if that makes sense. Can you tell me please ? <html> <head>
3
2199
by: Steven Bethard | last post by:
Within a larger pyparsing grammar, I have something that looks like:: wsj/00/wsj_0003.mrg When parsing this, I'd like to keep around both the full string, and the AAA_NNNN substring of it, so I'd like something like:: (, {}) How do I go about this? I was using something like::
7
5187
by: SNN | last post by:
Hi, I have 4 files that I would like to combine side by side and the seperater is tab in these four files. I also would like to have the output file to be tab delimited. All 4 files have the same legnth. I wrote the following script where I get an error message at the "k" loop. It does not understand "$#L$s" . what I would like is to print @L1 followed by @L2, @L3, and @L4 side by side with tab as a deliminator. #!/usr/bin/perl _w
5
1866
by: Yew12 | last post by:
I have been trying to update the details in a access database but, all I get is a white screen and all the errors I have built-in give me no help at all. All help is greatly appreciated. <html> <head><title> Customer Information Updated</title></head> <body> <?php
20
1936
by: arnimavidyarthy | last post by:
Hi, Hi, I am taking a string as an input from the user and it should only contain the chars:L , M or R I tried the folllowing in kodos but they are still not perfect:
0
9522
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10448
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10167
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9046
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6784
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5566
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.