Jump to content

Just A Few Questions


garyblackpool

Recommended Posts

hi sorry i about but this but rather than posting one topic at a time i thought i would just get this off my chest.In chmod, who are the user, group and owner and how does the computer recognize them?When do you use curly braces around variables?And when submitting a form when the user uses paragraphs can carriage returns be retained. I have used oscommerce but had to put <br /> in myself, should that of stripped tags?Thanks very much.Gary

Link to comment
Share on other sites

In chmod, who are the user, group and owner and how does the computer recognize them?
Those are Linux terms... mostly. As the note in chmod says, "The current user is the user under which PHP runs.". When you execute a process (i.e. a program) on your computer, that programs starts with the privilages of a certain user - your username. It could also be started as another user though. The OS manages (i.e. adds, edits, deletes, etc.) users. When you (or a program) start a program, you actually tell the OS to start a process with a certain username.Each user has a group. The current group is the group that the current user belongs to. Note that at least on Windows (Vista and later; I don't know about Linux), a user doesn't have to have a group.Every file has an owner. By default, the owner is the user that created the file. If the current user has the privilage to take ownership of a certain file, it can become its new owner. When a certain user is a file's owner, it can alter that file's permissions for all users.
When do you use curly braces around variables?
1. When you have a double quoted string in which you want to get the value of the variable. For example:
$string = "World!";echo "Hello {$string}";//Hello World

2. When you want to get the value of the variable, which has a name that is the value of another variable. For example:

$string = "var1";$var1 = "Hello World!";echo ${$string};//Hello World!

In both cases, the curly braces are optional. In slightly more complicated scenarios though, they could be the only way to state exactly the thing you want, so it's a good habbit to place them even on these simpler cases.

And when submitting a form when the user uses paragraphs can carriage returns be retained. I have used oscommerce but had to put <br /> in myself, should that of stripped tags?
They are always retained... at least in the data that PHP receives. However, if you just "echo" the data, you're then outputting HTML. As you should know, in HTML, whitespaces are trimmed until only one space remains. You can surround the data with a <pre> element if you want the spaces in it preserved as they are. Alternatively, as you already do, you can replace the carrige returns and newlines with a <br /> element.
Link to comment
Share on other sites

In chmod, who are the user, group and owner and how does the computer recognize them?
http://www.zzee.com/solutions/unix-permissions.shtml.
When do you use curly braces around variables?
When you want to disambiguate them within a string, or for constructs who's placement within a string without distinction would be syntactically incorrect. For example:
echo "I am {$test['1']}.";

And when submitting a form when the user uses paragraphs can carriage returns be retained. I have used oscommerce but had to put <br /> in myself, should that of stripped tags?
Carriage returns are represented in a textarea's form data, however, they won't appear on a rendered page when placed within HTML code, as line breaks are ignored in HTML. You need to convert them to break tags using nl2br().
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...