Jump to content

command line questions


Ninjakreborn

Recommended Posts

I am studying here
[a href=\"http://www.hudzilla.org/phpbook/read.php/2_6_2\" target=\"_blank\"]http://www.hudzilla.org/phpbook/read.php/2_6_2[/a]
on that specific page, it speaks of various letters that do various things. What is a command line I think it's were you are using a server on your own computer, I will be working for people off there internet server. so I won't have a command line I don't think, it told me about /n would cause a line space. I tried that forever it didn't work, I had to start adding in <br /> to get it, so I know /n doesn't work, which of those others should I use a replacement for instead, and if so, what command would replace each of those like /n is replaced with <br /> when you are doing it on an internet hosting server.
Link to comment
Share on other sites

Your getting a little confused. Php is generally used to output html to a browser. Try this...
[code]
echo "here is a line\nand another";
[/code]
View it in your browser and you will see it all on one line, then, right click and go to [i]view source[/i], you will see it split onto two lines.

Yes this is most helpfull on the command line (terminal), but it also has its place in the browser evironment.

eg, If your reading data from a text file and you want to retain its formatting. $data = data from text file.
[code]
$data = nl2br($data);
echo $data
[/code]
The nl2br() function adds </ br> tags after newlines chars.
Link to comment
Share on other sites

Its not /n but \n also when using \n make sure you use it inside double quotes ie:
[code]echo "Hi\nBye";[/code]When you run that in a web browser it'll oinly display as HiBye however you'll notice that if you go to view -> source in the browser. Your newline is in fact there
[code]Hi
Bye[/code]

If you want a newline character you have to use the, line break tag (<br />). This is becuase the browser ignores whispace charaters.

But if you use the command line in Windows you'll need to do \r\n for a new line to be inserted otherwise windows wont put in new line character. Other OS like Linux require \n and Macs require \r

I would recommend you to download a software package called WAMP. WAMP includes Apache (we server), PHP and MySQL. This enables you to test your PHP scripts localy on your PC. This save a lot time as you have to keep using your clients server to test you scripts.
Link to comment
Share on other sites

I think I will do that, but I want to wait a little while because it sounds like I have to learn 2 syntax, one for web development and one for command line, and I don't have a server here, I don't understand anythign about setting up a test server, even with coldfusion, I don't understand any of that, but I am still presisng foward gathering bit by bit of information until i make it through the learning curve, you will see a lot of posts on here from me for awhile.
I don't understand lamp, or wamp, because I thought I had to have a server running from my home to install apache, and even if I did wouldn't I have to go through all my scripts and replace /n with <br />
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.