A small question that can be quickly answered

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

A small question that can be quickly answered

Post by Draco_03 »

I just need a good link to explain me what % and @ and other sign are used for..
as far as i know %with a number i think just give you a number of decimal you wanted.. like %2 or soemthing like that
@ i think is about error rpeort somehow.. god i don't know>>
please don't tell me to google.. i know how to google..just the keyword (not knowing php well enough) is kind hard.. php @ % ownt really work in google :)

so just a link..if you don't want to write it down..

thank you
8)
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

the @ sign your right about error.

Since i'm no good at explaining things, heres what the manual says on it.. (see error handling functions)
This will supress the injection of error messages into the data stream output to the web client. You might do this, for example, to supress the display of error messages were foo() a database function and the database server was down. However, you're probably better off using php configuration directives or error handling functions than using this feature.
people use it to make their own custom error sequence, its really of no great importance in my eyes.[/quote]
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

tim is right about the @ sign. As for the % sign, i've never seen it used like echo %2; NEVER!!! % is the modulus operator. Meaning it will return the remainder of a dvision problem... like:

9 % 2 = 1
100 % 13 = 9

Get it??

I'm also not that great at explaining things!!
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

Illusionist wrote:tim is right about the @ sign. As for the % sign, i've never seen it used like echo %2; NEVER!!! % is the modulus operator. Meaning it will return the remainder of a dvision problem... like:

9 % 2 = 1
100 % 13 = 9

Get it??

I'm also not that great at explaining things!!
The % symbol is also used for formatting in various print functions like sprintf and whatnot:
PHP Manual wrote: A type specifier that says what type the argument data should be treated as. Possible types:

% - a literal percent character. No argument is required.
b - the argument is treated as an integer, and presented as a binary number.
c - the argument is treated as an integer, and presented as the character with that ASCII value.
d - the argument is treated as an integer, and presented as a (signed) decimal number.
u - the argument is treated as an integer, and presented as an unsigned decimal number.
f - the argument is treated as a float, and presented as a floating-point number.
o - the argument is treated as an integer, and presented as an octal number.
s - the argument is treated as and presented as a string.
x - the argument is treated as an integer and presented as a hexadecimal number (with lowercase letters).
X - the argument is treated as an integer and presented as a hexadecimal number (with uppercase letters).
But I too would like to know when and why to use these.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

well, technically, the % sign can have different meanings. Its depending on what sitution you use it in.

If your familar with regular expressions, its the same as a peroid.

MySQL interprets the % sign as for like searches to match character strings. its considered a wild card meaning "anything or all" exact or sub-sets matches.ie

%tim% would match, timmy, tim, timber, timberwolf,timisdumb, etc. Get it? a percent sign matches any string of zero or more characters.

Or the above post, i'm not to familiar with it however so that is the best I can do.
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post by Draco_03 »

ty guys.. :)

tim about the %
%tim%
could you get something like mynameistimberlan?
..
Last edited by Draco_03 on Mon Mar 22, 2004 2:41 pm, edited 1 time in total.
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

Whiler we're on the subject, what about & ?
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

just a single '&' is a bitwise operator.

http://www.php.net/manual/en/language.o ... itwise.php
Post Reply