-
Posts
4,362 -
Joined
-
Last visited
-
Days Won
11
Posts posted by Zane
-
-
[quote=http://us2.php.net/manual/en/reserved.variables.php]
HTTP POST variables: $_POST
Note: Introduced in 4.1.0. In earlier versions, use $HTTP_POST_VARS.
[/quote] -
Every now and again I stumble on something about PHP I've never heard about.
I was looking at Operator Precedence and found a bitwise operator.
I looked further into it and found out there were more of those, but I have no clue where or when I would use them. I can't understand the examples.
Can anyone enlighten me here. Gimme a scenario were I'd use a bitwise operator?
Thanks -
wow..this is an interesting thread
well for my turn.
I'm 20 years old. I'm from the farthest west city you can go in North Carolina. For those of you who watch the news, it's the city where they caught [url=http://en.wikipedia.org/wiki/Eric_Robert_Rudolph]Eric Rudolph[/url] (one of the Top Ten Most Wanted)
The first time I remember really soaking myself into a computer was with an old Gateway2k running Windows 3.1 Never thought I would be making anything useful on one though. By the time high school rolled around I could take them apart and troubleshoot whatever as well as make some sort of cheesy website with Homestead/Geocities/Angelfire/ or Tripod. I can't even remember how I found PHP. I guess I just knew that I needed a way to create a form and found the best way and wala.
I go to a Community College aiming towards a Computer Technology Systems degree and am struggling through the welcome path to the "real world." I speak English and Spanish..(thanks to 10 years of dedication) and I like to party and get ~retarded. -
what's the way the date should correctly show.
take a look at the date funciton here http://www.php.net/date
and use this whole statement as the second argument
for instance
[code=php:0]
date("Y-m-d:h:m:s", strtotime("-1 hour", strtotime(mosCurrentDate())));
[/code] -
I think it would be a good idea to give your navation links a background-color and some padding instead of just being underlined.
It would seem more modular, if that's what you're going for.
Like the breaking news...if you gave each LI a background color -
echo strtotime("-1 hour", strtotime(mosCurrentDate()));
-
Well for one
[code]
it's supposed to be
$query="INSERT INTO movie (name, genre, description) VALUES ('$mname', '$genre', '$mdesc')";
$result = mysql_query($query)or die('Error!' . mysql_error());
[/code]
not
[quote]
$query ="INSERT INTO movie (name, genre, description) VALUES ("$mname", "$genre", "$mdesc")"
or die('Error!' . mysql_error());
mysql_query($query);
[/quote] -
check out this thread http://www.phpfreaks.com/forums/index.php/topic,95376.0.html
-
As long as you don't allow them to create variables make PHP statements
you should have to worry about malicious code.
if you block thing like
{
}
$
=
->
and as long as they don't have access to any global variables like _POST or _GET
there's nothing dangerous that could happen...
[quote]
To modify this to allow letters as well, I would use? (assuming I first make the input lowercase)
Code:
if(ereg("[^a-z0-9()\*\/\\\^\+-\s]+", $textInput))
echo "Not a Valid Mathmatical function";
else
eval($textInput);
[/quote]
yeah...you can also set for uppercase too
[^a-zA-Z0-9()\*\/\\\^\+-\s]
-
[code=php:0]
if(ereg("[^0-9()\*\/\\\^\+-\s]+", $textInput))
echo "Not a Valid Mathmatical function";
else
eval($textInput);
[/code] -
just do a regex validation on the text input
that only allows
[code]
(, ), ^, *, /, \, +, -, [0-9]
[/code]
EDIT:
didn't realize the question was about regex already..lol -
this should do it
[code=php:0]
function codeMode($arr, $value) {
$count = 0;
foreach($arr as $val) {
if($val == $value)
$count = 0;
else
$count++;
}
return $count;
}
[/code]
EDIT: wait..no it won't gimme a sec
here
[code=php:0]
function codeMode($arr, $value) {
$count = array();
$i = 0;
foreach($arr as $val) {
if($val == $value)
$i++;
else {
$count[$i]++;
}
}
rsort($count);
return $count[0];
}
[/code] -
A bit odd of a question for me..
I see people using sprintf() a lot in their code.
Which in turn you could do the same thing with echo
what is so good about sprintf and printf as opposed to echo or print.
Cuz all I recognize from sprintf is that you put you're placeholders and then you're variables at the end
I could just as easily say
echo "My name is {$name}";
instead of
sprintf("My name is %s", $name);
What are the benefits? -
[quote author=mjurmann link=topic=110717.msg448148#msg448148 date=1160156521]
Ray, I don't see in my code where I had $_SESSION['$firstname']
[/quote]
well what's this
[quote]
<div align="left">Name (First): </div></td>
<td width="64%"><label>
<div align="left"><?php echo [b]$_SESSION['$firstName'][/b]?>
</div>
</label>
[/quote] -
=== or !== is a strict comparison....to compare both the value AND the variable type
== or != is a basic comparison....to compare just the value
for instance
[code=php:0]
var_dump(false == 0); //displays true
var_dump(false !=== 0); //displays false
[/code] -
Back about 6 years ago...one of my friends started to call me Zanus
as if to insult me, in a friendly way. I'd get upset about it sometimes but when they eventually kept calling me that it stuck and everyone else decided to tag that name to me.
My real name is Zane....
and I've had such phrases like Zane the Pain come about a thousand-teen times in my life.
after Zanus...it became Zanus the painus in the anus..lol
Maybe that's an interesting story...I dunno
if I'm not using zanus...I use dockeryz...which is just my last name and first initial -
look at the strrev() function
http://php.net/strrev -
I don't think that it would....
you'd have to say declare the same function everytime like that...resulting in a new object each time...
for instance if you said
FuncReturnsObj()->b = "foo";
and then
FuncReturnsObj()->b += "bar";
if you tried to echo
FuncReturnsObj()->b it would still be undefined
this is one way of doing what you're talking about
$obj = new a();
$b = $obj->getOtherObject();
$b->myFunction();
-
right here
$newobject = new b();
return $b;
you have to return the object $newObject
$b doesn't exist
and the reason you get this error
T_OBJECT_OPERATOR.
is because function aren't meant to have methods or properties
so a -> operator on a function is unexpected to PHP
you have to store the return of getOtherObject() in another property of Class A -
First make sure you don't have any firewalls covering Apache
and if you're running your internet through a router, you need to turn on DMZ for your computer through the router control panel....
I've only setup a webserver like that once or twice...from my home computer
but I know that those steps where involved.
Also if you have a domain name you can look at places like
http://www.zoneedit.com for DNS redirects and all that
-
You know what, I wrote that whole thing and completely forgot I was supposed to be discussing a Contest.
the word "Extreme Makeover: Website Addition" utterly through me off
-
I like the second idea...
[quote]
b) pick a crappy site and we have a "team" of people all work on it together, kind of like on the linkie I had in my previous post, where a "team" of people go and re-do a home and make it better.
[/quote]
It seems like an awfully big responsibility to take on a whole website, just for kicks
I know everyone here is really good at one particular thing unique from the rest, and if it were combined into like a joint application development team...I think it'd make for a much nicer website.
probably 70% of the people on here knows all the chores of a website creation...but surely there's that one person that is rediculously good at SQL, and the other guy who can CSS up a .... building?
Like for instance
I prefer making classes and making them work with what's available on the site. -
Whenever you get an error likie this
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/www/os.xephor.net/catalog/account.php on line 152
it means you have an error in you Query...
so go check the syntax of your SQL query
best way is to get rid of the @ symbol in front of your mysql_query function
and put this at the end of that line....before the semicolon
or die(mysql_error()); -
Yeah, I could only see that idea being used on an as needed basis....seeing as it doesn't append to your class but your object.
bitwise operators
in FAQ/Code Snippet Repository
Posted
&= is an assignment operator not a bitwise.
Assign by reference I believe it's called.
I understand how references work, I was wondering how such operators like these work
$a & $b
$a | $b
$a ^ $b
~ $a
$a << $b
$a >> $b