Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. You can use array_rand. Ex: $messages = Array('Message 1', 'Message 2', 'Message 3'); echo $messages[array_rand($messages)];
  2. Yea, and it might even be possible to do this all within one query, again, it depends on your circumstances.
  3. Related: http://googleblog.blogspot.com/2009/12/now-you-see-it-now-you-dont.html (even though it's kind of old news..)
  4. $im = imagecreatefrompng($_SESSION['image'] . '.png'); I suggest you take a look at the documentation on strings
  5. = is the assignment operator, you need to use the comparison operator ==. if($Count==1)
  6. It seems like these life decisions come easier to others. I've been struggling for years trying to determine a career path. Being extremely indecisive in general doesn't help when it comes to such big decisions. A large majority of my peers didn't have a hard time deciding what they want to do, but for me it's just not that easy. I do love programming, and I don't see myself getting out of it anytime soon, but there are just so many things to consider. Salary, what education is required, and actually being able to find a job after college.. which might not be so easy from my research, IT jobs are declining. I've considered a lot of other things, for a little while I was strongly considering going into theoretical physics, or perhaps astrophysics. The problem with this is the salary isn't that great, and the best opportunities (at least money wise) seem to be as college professors later on in years, which I'm not too interested. Although, money isn't everything, and it is really amazing to have the opportunity to be working on the forefront of human knowledge. I still don't think this is right for me. Seeing a lot of you who have the same passion for programming that I have and actually deciding to go after jobs in these fields is making me think. To those of you who have decided to go after a career in what they love.. programming.. was it hard for you to make your decision, or am I just being overly stubborn?
  7. In php you can define function arguments to be of a certain type. You'll generate exceptions if argument then passed to these functions aren't the correct type. eg; function foo(array $arg) {} To be clear this only tests for object types, not for all data types. This works for arrays because well.. arrays are objects of type array. But if you try to do something like: function func(int $arg) { ... } it won't work as you might expect because it's looking for an object of type int, and not the data-type int.
  8. Not lame, but the part with trying to name files with question marks was hilarious. I remember long before I was too interested in programming I attempted to do some small websites, designs and stuff with photoshop. I had like no experience so I thought all these divs and stuff were made primarily with background images. Trying to put together body backgrounds with header and footer background images perfectly so they actually lined up, which was hard considering the only thing I knew how to do was to manually put transparent margins on the actual images..
  9. How and why did you get involved with web development, and what is it to you? Is it a hobby, a career, a side-job or what? My Answer: For me web development is more of a hobby than anything else at the moment, or perhaps an obsession would be more fitting. I think originally the reason I got interested in web development is because on a forum that my friend owned there was a PHP section, and I guess I was uncomfortable with them knowing something I didn't It started out as something small, but it escalated quickly and became somewhat of an obsession. Because I started web development, and programming in general, at such a young age I really had a lot of time to invest in studying it as I didn't have anything too time-consuming on my schedule like a job, or school (as it was extremely easy at this point). It started out as just making some cool stuff, and even now it's not really much more than a hobby. I do some freelancing here and there, but it's nothing serious and I'm not too interested in it currently. I haven't really decided if web development or programming is ever going to play a bigger role than just a hobby in my life. Because I'm younger than the average user here on PHP Freaks I haven't made an absolute decision on what career path I'm going to take is, but it's time for me to start getting serious about my future. Currently I'm a junior in high school which means college is right around the corner. Up until recently I haven't even really considered an actually career in web development/programming just because it felt like more of a leisure time activity. But now computer science is definitely a candidate for my major in college. -- What about you?
  10. If you're putting that in core.php the include must be before you try to access the object.
  11. You're going to need to do a little of math to make the text be centered no matter what the string is. To calculate the starting point of the text we need to do: The width of the entire image / 2 - string width / 2. To find the string width of a ttf font we can use imagettfbbox. Example: $bounds = imagettfbbox(35, 0, 'arial.ttf', $_GET['number']); $start_x = IMAGE_WIDTH / 2 - ($bounds[2] - $bounds[0]) / 2; // $bounds[2] - $bounds[0] will be the width of the string, check the documentation for more info. Untested, but should work. Make sure to replace IMAGE_WIDTH with the width of the image ($im) that you're dealing with. imagettfbbox
  12. Yeah, metal deceases are bad.
  13. One solution would be to use preg_replace_callback. Ex: $file = <<<FILE \$var = "test file"; \$var2 = base64_decode('ZXhhbXBsZQ=='); \$test = array(base64_decode('ZXhwZXJpbWVudA==') => 'example'); FILE; $file = preg_replace_callback("~base64_decode\('(.+?)'\)~", create_function('$arg', 'return "\'" . base64_decode($arg[1]) . "\'";'), $file); echo '<pre>' . $file . '</pre>'; Output: $var = "test file"; $var2 = 'example'; $test = array('experiment' => 'example');
  14. Do you need to echo the list as well as send it in the message? If so it would be preferable to use output buffering. Ex: if(isset($_POST['language'])) { ob_start(); $language = $_POST['language']; $n = count($language); $i = 0; echo "The languages you selected are \r\n" . "<ol>"; while ($i < $n) { echo "<li>{$language[$i]}</li> \r\n"; $i++; } echo "</ol>"; $list = ob_get_contents(); } You can then use $list inside of $message.
  15. Given sufficient magnification you would be able to see anything regardless of size. Just because a piece of technology doesn't exist doesn't mean it cannot exist. Yes, of course, and I wasn't stating otherwise. I was just saying that at current we don't posses the the technology. Actually, there is a practical hard limit -- magnification requires a lens to bring the image into focus, and that lens has to be smooth, or the resulting image will be fuzzy. And you can't polish a lens to be infinitely smooth -- in fact, it's pratically impossible to focus x-rays at all, which have a wavelength on the order of magnitude of atomic resolution. In my other life, I did years of graduate training to work around this exact problem -- it's a royal pain in the butt. I wasn't really agreeing with the fact that you can magnify an infinite amount, but rather that it would be possible to magnify enough to see atoms, eventually. I guess I should have made that clear.
  16. I've done this before, but usually it's done the other way around: You have the forum already setup and you want their forum accounts to also work on the main website as well.
  17. I can't seem to think, and I'm not that great at regex anyway, this will work, but there are probably better solutions. $string = "/home/carlos/web/swme-site-generator/swme-contact-me.txt"; echo strrev(preg_replace('~-emws~', '', strrev($string), 1));
  18. Are you just trying to get the file name from the path? If so regex, although it will work, isn't the best solution. You could just do this: $string = "/home/carlos/web/swme-site-generator/swme-contact-me.txt"; echo pathinfo($string, PATHINFO_BASENAME); If you want the preceding forward slash you can just append that.
  19. You have a scope problem. The $count you declared outside of the function doesn't exist inside the scope of that function. You need to declare it inside that function, or use the keyword global, which is a bad practice and I wouldn't suggest the use of it.
  20. Given sufficient magnification you would be able to see anything regardless of size. Just because a piece of technology doesn't exist doesn't mean it cannot exist. Yes, of course, and I wasn't stating otherwise. I was just saying that at current we don't posses the the technology.
  21. Not that any type of microscope powerful enough to view atoms even exists in the first place. The only way that we can actually generate images of atoms is through STMs, whose images aren't actually images of the atoms themselves but computer generated depictions based on data acquired.
  22. 'Invisible' by definition, refers what to what is undetectable by the human eye. http://dictionary.reference.com/browse/invisible
  23. Air is not invisible. Air isn't a constant and varies, but generally the 3 major components of air are Nitrogen, Oxygen and Argon, all are color-less gases at STP.
  24. This isn't really a problem with the ID skipping. If every time you deleted a row all the unique ids shifted down that would kind of defeat the purpose, wouldn't it? It wouldn't be a constant anymore. If this gap is giving you a problem then it's likely it's a design flaw in your program. If you want to select a random record from a database you can use ORDER BY RAND() LIMIT 1. This doesn't scale well, so if you're dealing with a large database you might want to look into some of the alternatives, there's a sticky for this in the MySQL forum.
×
×
  • 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.