Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. That's not exactly accurate. PHP can be complied into stand-alone applications with things like Roadsend compile, PriadoBlender, etc..
  2. Yea, back-ticks should only be used if you're using a word that's reserved, which you should avoid to start with.
  3. As I said before $race isn't defined before you use it. Do you mean: $classfunction = $_POST['race'] . '-functions.php'; ? Edit, just move your defining of $race to above where you're using it..
  4. Post your code, we can't help without seeing what you're doing wrong.
  5. Of course that's possible. Maybe the problem with the code is that you're defining $race after it's used in the file's name?
  6. You can try something like: $string = "First paragraph.\n\nSecond paragraph.[codetag]Code\n\nA few lines later[/codetag]."; $split = preg_split('~\[/?codetag\]~', $string); for($i = 0;$i < count($split);$i++) $out .= ($i % 2) ? '</p><code>' . $split[$i] . '</code>' : str_replace("\n\n", '</p><p>', $split[$i]); echo $out;
  7. The best way would be to use regex. ex: $text = preg_replace("(\[codetag\](.+?)\[\/codetag])is",'<code>$1</code>', $text); preg_replace() The example will replace all text inside of [codetag][/codetag] with <code>text here</code>
  8. Like this: $result = mysql_query($sql); while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { echo $row['image']; }
  9. You should probably post your full child class, but I'm about to go to sleep in a few minutes so I don't know how much help I can be.
  10. I didn't see anything wrong with that. So I created a quick example, and as I thought it works fine. So there must be a problem somewhere else.. ex: abstract class ParentClass { protected function someMethod() { echo 'Works'; } } class childClass extends ParentClass { public function callParentMethod() { $this->someMethod(); } } $cl = new childClass(); $cl->callParentMethod(); Works.
  11. session_destroy()? Or do you mean like: unset($_SESSION['var']) ?
  12. You're missing a ; on this line: mysql_close()
  13. You should learn more about scopes, as that's your issue. The variable within the function isn't accessable outside of that scope, but since you're returning all you need to do is: $s_status = ServerStatus($server);
  14. $_SESSION is a super-global, it'll only be accessible on pages that have session_start() on them. Note: make sure you call session_start() before any output or you'll get a headers already sent error.
  15. Since it works I'd say so You don't really need a function for that though. All your function is accomplishing is returning the result of another function or more less, pretty redundant. If you're looking to echo it like your function: echo (strtotime($time)) ? 'Pass' : 'Fail'; Or more likely to be used, in a conditional: if(strtotime($time)) { }
  16. Sure, use explode() $var = 'wait.for.me'; $split = explode('.', $var); echo $split[0]; // wait echo $split[1]; // for
  17. Erm, I beg to differ... CODE: <?php function check_time($time) { if(strtotime($str)) { return "PASS<br/>"; } else { return "FAIL<br/>"; } } echo check_time("25:10"); echo check_time("12:68"); echo check_time("24:14"); echo check_time("23:14"); echo check_time("00:14"); ?> OUTPUT: That wouldn't output that. It wouldn't even work because $str isn't defined within the scope of that function. I know you probably just put that together and perhaps made up the results because you know it's right or something, but I'd advise against that; no one is perfect and you could have made a mistake and you'll just end up causing confusion.
  18. I think he means because count($hello) won't have to be pre-preformed every loop. The time difference would be so minimal.. it really wouldn't matter. Personally I'd use Mikesta707's method only because there's no need for that additional variable / line when it's going to save 0.000001 second. The general fluctuations in execution time would be considerably larger than the time that might save.
  19. Ticker tape? You want to display a method of transmitting stock market prices over telegraph lines?
  20. Alex

    $this->

    $this is used to access a property or method of a class that you're currently in. eg: class SomeClass { private $name = 'Alex'; function __construct() { echo $this->name; } } $class = new SomeClass(); // Alex I'd suggest you read up on PHP OOP
  21. The syntax is: if($total == 5 || $total == 10) { } Etc..
  22. <?php $_SESSION["qty"][$key] = 1; echo $_SESSION["qty"][$key]; ?>
  23. Try this: foreach($item as $key => $val) { echo '<li><a href="#">' . $key . '</a></li>'; } You're misunderstanding the functionality of the foreach. I suggest checking out the manual
  24. 1. Why don't you try it yourself? 2. This isn't a request board, it's a help forum. If you have a question about exactly why it outputs what it outputs, that's a reasonable question.
×
×
  • 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.