Jump to content

BrianPeiris

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

BrianPeiris's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. AH! you are absolutely correct. well done, that makes things much clearer! In fact, thanks to you, I found a solution: [code] <?php $_GET['work']=0; $file='test2.php'; function get_include_contents($filename) { ob_start();         //include($file);         $GLOBALS['tempVar'] = " HELLO!";         function doTest()         {       global $tempVar;       echo $tempVar;         }         doTest(); $contents = ob_get_contents(); ob_end_clean(); return $contents; } if($_GET['work']) { echo "This works!"; ob_start(); //include($file);         $GLOBALS['tempVar'] = " HELLO!";         function doTest()         {       global $tempVar;       echo $tempVar;         }         doTest(); $contents = ob_get_contents(); ob_end_clean(); } else { echo "This doesn't work!"; $contents = get_include_contents($file); } echo($contents); ?> [/code] Now 'tempVar' is truly defined in the global scope and not just in the scope of 'get_include_contents'. Thanks again!
  2. There is a way to use the Google Maps API with your own custom map layer/tiles, for an example: [url=http://mapwow.com/]http://mapwow.com/[/url] See the following links. [url=http://www.econym.demon.co.uk/googlemaps/custommap.htm]http://www.econym.demon.co.uk/googlemaps/custommap.htm[/url] [url=http://mapki.com/wiki/Add_Your_Own_Custom_Map]http://mapki.com/wiki/Add_Your_Own_Custom_Map[/url] I really don't suggest trying to redo Google maps, it would be an immense amount of work to get all the logic down, let alone getting it to work in various browsers. But... If you really want to, take a look at this: [url=http://media.pragprog.com/titles/ajax/ajaxian_maps.pdf]http://media.pragprog.com/titles/ajax/ajaxian_maps.pdf[/url]
  3. so you're saying it won't divide even though both $a and $b are numeric! That is very strange. If possible please post a simple test case, inside and outside a class, that shows the problem. What version of PHP are you using?
  4. hmm, Are you sure they are numeric? If you can replicate the bug, the best way to find out what is happening is to print out $a and $b to truly tell what they are: [code] function percent($a, $b) {     var_dump($a);     var_dump($b);     $percent = round(($a / $b) * 100);//line 83     return $percent; } echo(percent(3,2));[/code] This would output: [code]int(3) int(2) 150[/code]
  5. chances are either $a or $b is not numeric, and you can't divide or multiply values that are not numeric (though there are some exceptions) So make sure your function receives numeric values for $a and $b. For example, the following code will give you the same error: $a = 8; $b = array('ping','pong'); echo($a/$b); OR $a = 'ping'; $b = getdate(); echo($a/$b);
  6. you might also want to remove the '@' (at sign) in front of 'mysql_query' during testing, so that you see any and all errors that might be suppressed. Docs on Error Control Operators:[url=http://|http://ca3.php.net/manual/en/language.operators.errorcontrol.php]|http://ca3.php.net/manual/en/language.operators.errorcontrol.php[/url]
  7. Hello everybody, I'm new here but I'm a novice with PHP. I've been racking my brain for the past couple of hours with this problem, so I hope you can help me out. So I've got two PHP files, one file (test1.php) [i]includes[/i] the parsed contents of the other (test2.php) using the output buffer functions (ob_start, ob_get_contents, ob_end_clean). The special condition is that test2.php uses a global variable in its code. It seems to work, except when I refactor the code in test1.php into a function, it stops working. Here's a test case: [url=http://brianpeiris.com/test/test1.php?work=1]http://brianpeiris.com/test/test1.php?work=1[/url] - This link shows the output of the working code. [url=http://brianpeiris.com/test/test1.php?work=0]http://brianpeiris.com/test/test1.php?work=0[/url] - This link shows the output of the broken code. Here are the source files: [url=http://brianpeiris.com/test/test1.php.txt]http://brianpeiris.com/test/test1.php.txt[/url] [url=http://brianpeiris.com/test/test2.php.txt]http://brianpeiris.com/test/test2.php.txt[/url] The problem occurs on both PHP4 and PHP5. TIA, Brian.
×
×
  • 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.