Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. probably because of the abuse and chaos that would ensue. Can you imagine every site on the planet being able to grab the current highest ranking keywords and have their content dynamically generated based on it?
  2. the business world likes familiarity. They have the deepest pockets. Do the math.
  3. read the sticky.
  4. I provide comedy relief and examples of what NOT to do
  5. Yes. That is the point of it being a local variable. function something() { var x = 'blah'; } alert(x); // this will give you an error in this example, x is local to function something(). It only exists inside that function, and when the function ends, the variable is destroyed. Now what you can do is return the value of x. Example: function something() { var x = 'blah'; return x; // this will return 'blah' to whatever called the function } var y = something(); // since 'blah' is being returned, you can assign it to a variable alert(y); // this will echo 'blah' alert(something()); // alternatively, this will also echo 'blah'
  6. hmm actually on 2nd look that is gonna evaluate true every time there is a dot in there somewhere. You will have to assign value.match(..) to a var and then check if variable[1] exists
  7. if( !value.match(/\.(doc|jpg|pdf)$/) ){ that will only check for those 3 file types though..
  8. well I suppose you could have them all in a directory and then grab all files from the directory and loop through them, echoing out script and/or link tags.
  9. Right. IE8, IE8->IE7 compatible, and IE7. No IE6
  10. in that code, name2 is local to the function, so it only exists within that function, and only when the function is actually executing. So when you try to pass it as an argument to the function, javascript is looking for a global name2 variable. Since there is none, you are passing null to the function, so 'who' is null. Also, inside your function, you are assigning something to name2 but not actually doing anything with it. A global variable is a variable that is set outside of the function, and can be accessed inside the function. A local variable is set inside the function and can only be accessed within that function. example1: // this is a variable being set globally var x = 'hello'; // this is a global variable being used on global level alert(x); // will alert 'hello' example2: // this is a variable being set globally var x = 'hello'; function blah() { // this is a global variable being used locally alert(x); // will alert 'hello' } blah(); example3: function blah() { // this is a local variable being set locally var x = 'hello'; alert(x); // will alert 'hello' } blah(); alert(x); //this will give you an error because x is not defined on the global level In your example code (the last one you posted) you are trying to pass 'name2' to Greet() but 'name2' doesn't exist on the global level, so it passes a null value to 'who'. Then you assign 'barney' to name2 but that's a local variable so after the function ends, name2 gets destroyed, so when you call Greet() a 2nd time, it's not going to be there just the same. Inside a function the local variable takes precedence, but it's not quite as it seems it should be. Example4 var x = 10; function blah() { var x = 20; alert(x); // alerts 20 } blah(); alert(x); // alerts 10 In this example, 20 gets alerted inside the function, and 10 gets alerted outside of the function. Well here's the caveat: example5: var x = 10; function blah() { alert(x); // you would think this would alert 10, but it alerts 'undefined' var x = 20; alert(x); // alerts 20 } blah(); alert(x); // alerts 10 So why does that first alert(x) show 'undefined'? It seems as though it should alert 10, right? But it doesn't. I don't know 100% why but I think it has to do with how js is parsed internally. Like, it pre-parses the function and sees that somewhere down the line you're going to be overwriting the global x with a local x and therefore kills the global reference, but since the var x = 20 isn't actually parsed at that point, it's showing up as undefined. That's my best guess, anyways. Maybe someone better versed in javascript can confirm/clarify.
  11. I think you are saying you want to have a word filter but you want the word filter to ignore anything inside an html tag? $string = preg_replace('~((?!<[^>]*))swear_word~','{$1}nice_word',$string); If that is not what you mean, try posting back to back a couple of "before" and "after" examples like BEFORE AFTER BEFORE AFTER BEFORE AFTER
  12. var name1 = "Fred"; var name2 = "Ethel"; those are global variables, because they are assigned outside of a function. var name2 = "Barney"; Is the local variable, as it is assigned inside the function. If you did this in your function instead: name2 = "Barney"; it would be assigning "Barney" to the global variable you already established. But you have 'var' in front of it in your variable, which creates a local variable with the same name as your global variable. If you remove that 'var' in front of it in your function, the next time it is called, it will show "Barney". The keyword being the next time, because you are assigning it after the alert.
  13. use session variables (google php sessions)
  14. i'm about 85% sure it's a recent thing (3.5) I vaguely recall some other thread in the past indirectly mentioning it as a new thing or something.
  15. okay it looks like your goal is that you WANT users to access it when they are logged in, you already have stuff in place to only let them access it if they are, but you only want them to access it if $username is in the url. Well if they are already logged in, and you are just redirecting to the same page except putting their already established username in the url...that means you must already have that info in the session somewhere, so there's really no point in redirecting like that.
  16. you are redirecting it to the same page...so there's no need to redirect it...just change your condition to automatically grab it in the first place, if not from the url, then from the session variable (or kick them to the login if neither exist)
  17. yes. Basically it's just like a hit counter script, in principle. <?php // connect to db... if ($_GET['id']) { $id = (int) $_GET['id']; $sql = "update table set column=column+1 where id=$id"; mysql_query($sql); } ?> <a href='?id=1'>pray for this user</a>
  18. on my trip out here i realized i was going to be flying back today and thought about bringing a parachute onboard but then I figured I probably wouldn't make it past the security checkpoint. They'd be like "...you are bringing a parachute onboard because.....TERRORIST! <alarm sounds>"
  19. I'm sitting at the airport right now and my flight home has already been delayed twice.
  20. what line # does the error say and point out which line that is
  21. my sole purpose in (phpfreaks) life is to get myself quoted in sigs. Score!
  22. I don't have it, but one of my friends bought it recently and after playing it for about 30m he took the disc out and tried to stick his penis in the hole and fuck it. I guess that means it's good.
×
×
  • 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.