Jump to content

darth_tater

Members
  • Posts

    26
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Male
  • Location
    127.0.0.1

darth_tater's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok, thanks! Thats exactly the answer i was looking for. And i'll be using unset for: 1) security - you cant read or access or write a variable that no longer exists. 2) conservation - Lets not waste ram if we don't have to. i am actively developing a web app that could end up using 20+ classes for the most complex pages.... Any optimization i can do as i am writing these functions / classes i'll need later down the road!
  2. This is more of a technical question that i could not find the answer to pn the php.net manual pages. take the folowing example code: foreach ($array as $key => $value){ $tempvariable = some_property_of($value); } unset($tempvariable); is that unset statement needed? Does PHP automatically destroy the variables once the foreach loop is left?
  3. We're gona need a bit more information than that... how is this script supposed to work? does it just make up the email addresses and tracking numbers? where do those come from? You should start reading on how to generate an email and how to use the email sending commands in PHP. google is your friend here. It sounds like that'll be your biggest problem.
  4. Thats good to hear, lifeman211 ! Now please mark this as solved and use proper code tags next time and lets keep the excessive fonts/colors/sizes down to a minimum... Thanks
  5. Woo! i was playing around a bit more when it suddenly occurred to me! I wasn't giving PHP a reason to separate out the two! here is what i have now (and it works!) foreach($this->validArray as $key => $val ){ echo("<br><br> trying vdump of KEYs<br><br>"); var_dump($key); } before i did not have the => $val. Including it tells PHP that i want to seperate the KEY (the file name!) from the value (the sub-dimensional array) Problem solved! - thread marked as such!
  6. That gets me access to the 2nd dimension arrays. I dont need / want that. each array is built like this: array(2) { ["folder.jpg"]=> array(2) { ["valid"]=> bool(true) ["error"]=> bool(false) } ["file.mp3"]=> array(2) { ["valid"]=> bool(true) ["error"]=> bool(false) } } I need access to the folder.jpg and file.mp3, the first and second elements in the array. the foreach i have now should work but it returns the secondary array (which i dont need) not the string that is the first and second element in the 1st dimension
  7. google for more, but there are 8 bits in 1 byte and going from 1 -> kilo -> mega -> giga - >tera is always an increase by a factor of 1000/1024 (depends if your a hardware or software guy)
  8. Google. It's an awesome tool. http://lmgtfy.com/?q=100000+bytes+to+MB
  9. Hey all. another quick question. here is the output of my 2D array: array(2) { ["folder.jpg"]=> array(2) { ["valid"]=> bool(true) ["error"]=> bool(false) } ["file.mp3"]=> array(2) { ["valid"]=> bool(true) ["error"]=> bool(false) } } how can i foreach my way into getting an iterator that points to the folder.jpg and file.mp3? as is now, i have something that looks like this: foreach($arr as $val){ var_dump($val) } the var_dump of $val is an *array*. Thanks for your help!
  10. Can you post working and non working copies of your text files? also, USE THE tags!!!! it is very difficult to read your code w/o them! I don't have a whole lot of experience when it comes to dealing with files, but $raw_text = file_get_contents($url) should work.... add in some debugging statements as each variable is allocated and filled so you know if you're allocating them and filling them correctly.
  11. Also, don't just echo variables. use the command var_dump($variable); that will give you a TON more information about the particular variable you're trying to access. It is super useful for debugging the content of arrays!
  12. Thanks! i knew it had to be something simple :/ marked as solved!
  13. I know this is a simple question, but it's been bugging the hell out of me. i am being told that i have an undefined variable - errorString - in a function, even though it *clearly* is defined w/i the scope of the function. Can somebody please help me out? [undefined variable: errorString/code] [code=php:0] /** * is fed a string email address and processes it to make sure that we're within limits: * * 1) must not be empty * 2) must not be above 50 characters * 3) must be in name@example.tld format * * returns TRUE if email is valid, string (with reasons for failure) if the email is not valid * * @param string $email * @return boolean|string */ public static function data_validateEmail($email){ // set up temporary vaiable $errorString; // check to see if the user's email is a null string if (empty($email)){ $errorString .="You must supply an email address. "; } // then check to see if its under 50 characters if(strlen($email) > 50){ $errorString .= "The email address can be no longer than 50 characters. "; } // then make sure it's in teh correct format if (!preg_match('/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i', $email)) { $errorString .= "The email address must be in the name@domain.tld format. "; } // if we've got a valid email, return true... else, we return a string error if(empty($errorString)){ return true; } else { return $errorString; } } errorString is defined at the beginning of the function, so why am i told that it is undefined when, say, the length test fails? I know this has to be a simple solution, but ive spent almost 2 hours looking at it trying to figure it out, and have gotten nowhere.... and yes, part of that 2 hours was searching google for information about how PHP does variable scope in functions with multiple if statements... and all i could find was that as long as the variable is defined in the function scope, it should be available within the successive if statements. Thanks for reading![/code]
  14. Lets go over how do do the blinking first. you'll want to use pack http://php.net/manual/en/function.pack.php to take a number (say from 1- and turn it into binary. then you'll need a loop going from 1-8, calling pack with the current number that you're on, and passing that as an array / argument on to your function that writes to the parallel port. here is a link that should get you started on writing to ports in windows. http://www.governmentsecurity.org/forum/index.php?showtopic=16247 good luck!
  15. ^ That. about 100000 times. Yes, there is a reason, and it is a very bad one. Coding w/o little sleep. That and the function i am having this issue with started out as a copy / paste of another function in the same class that *is* and *needs to be* static. In copying/pasting/not thinking (i was lazy and tired) to save my self mere seconds, i created a 2 hour time suck. Thanks for helping me realize i am a bit of an idiot !
×
×
  • 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.