LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-19-2005, 10:23 PM   #1
blizunt7
Member
 
Registered: Mar 2004
Distribution: Fedora Core 1,2,3, RHEL3,4,5 Ubuntu
Posts: 274

Rep: Reputation: 30
php + newline???


hey all, ive got this code:

$info = 'First name: ' . $_POST['firstName'] .
' Last name: ' . $_POST['lastName'] .
' Email: ' . $_POST['E-mail'] .
' IP: ' . $_SERVER['REMOTE_ADDR'] . "\n";

THis is used to print to a file, given these inputs from an html form.
As i am new to php
1) What are the dots for?? And why must I place a dot before and after the $_POST[var]

2) HOw can i insert a newline char after each var is displayed???
Example:
$info = 'First name: ' . $_POST['firstName'] . "\n"
' Last name: ' . $_POST['lastName'] . "\n"
' Email: ' . $_POST['E-mail'] . "\n"
' IP: ' . $_SERVER['REMOTE_ADDR'] . "\n";


Thanks!
josh
 
Old 06-19-2005, 11:44 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,430

Rep: Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786
1. The dot '.' is the string concatenation operator. You can't just enclose the whole lot in 1 set of quotes, it won't interpolate the POST vars correctly.
2. you're nearly there, but you need to add '.' after each newline ("\n"), or print to the tgt file as separate strings.

you may find this link useful: defnitions of entire lang + lots of examples:http://www.php.net/manual/en/
HTH
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
newline problem harrylmh Programming 4 11-21-2005 04:04 AM
Newline in xmessage? scottjwoodford Linux - General 2 06-09-2005 03:17 PM
Bash Script for a newline olefemmy Programming 1 11-11-2004 11:16 PM
Removing newline. Tarts Programming 2 10-16-2003 11:49 AM
What is a newline? raptorsoft2000 Linux - Newbie 6 08-04-2003 10:05 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration