Jump to content

sneskid

Members
  • Posts

    38
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

sneskid's Achievements

Member

Member (2/5)

0

Reputation

  1. don't worry about the code, it's the url syntax that im asking about. Say you ping "www.electionsites.ca" from the command prompt in windows. you'll get a reply from 74.52.10.226. Now if you use a browser to visit "http://74.52.10.226" you will see a cPanel screen not electionsites.ca, because the server hosts more than one domain. my question is how to access the site using the ip syntax. Something like "http://74.52.10.226/electionsites/"?
  2. I'm trying to write a script that can connect to a domain using it's IP address. But I'm dealing with a multi-domain server, so the IP address needs an additional string describing which domain I want to access. I've seen it done before but forgot the syntax. It's an apache server with cPanel. Help? Thanks.
  3. I've always been raised to believe ( I make it sound religious almost ) that: x++ means: take x as is, at this moment in time (not later) and apply that value in the current operation (one would expect the compiler to be using temporary variables at this point) THEN immediately increment it by 1. THEN continue with the rest of the operation. ++x means: increment x by 1 NOW, THEN use the new value, THEN continue the operation. operation: be it arithmetic, function calls, array index assignments, echo messages, whatever. Thus 42 and 56 are as expected. and $x=1; echo add($x++,$x++); should echo 3 and leave $x as 3. (and it does, yay) But I'm sure we can all agree that $x=1; $a[$x] = $x++; should be $a[1] = 1 NOT $a[2] = 1; (which I would accept if this was legal: $a[&$x] = $x++ and leave $x=2 So 4.3.10 has it right, and 5.1.4 got lazy? This behavior says "yea, I'll check that variable later, saves memory, PHP is way too bloated... who cares about the foundation of programming as we know it." and I have an issue with that, the kind of issue that makes me want to divorce PHP and marry Perl.
  4. (v5.1.4) function xyz(&$v){$v++;return $v;} $a = array(); $b=0; $a[$b] = $b++; // [1]=>int(0) $a[$b] = ++$b; // [2]=>int(2) $a[$b] = xyz($b); // [3]=>int(3) $a[$c=$b] = xyz($b); // [3]=>int(4) $c negates the bug|feature var_dump($a); When $b is altered on the right side, it alters the expected assign-to index of $a on the left side. This shows that the left side evaluation can be effected after the right side evaluation. In other languages, for example Javascript, $a[$b] would have first been evaluated&locked as $a[0].
  5. in case you are wondering, i tried having the & at the function params too, no effect. Having the function create the "array workaround" makes things nicer and more transparent: function abc(&$v=0){ static $r=array(); if($v) $r[]=&$v; // or just $r = array('test'=>&$v); else var_dump($r); } $test1 = 'hello'; $test2 = 'stuff'; abc($test1); abc($test2); $test1 = 'bye'; $test2 = 'things'; abc();
  6. say you have this: function abc($v=0){ static $r; if($v) $r = &$v; var_dump($r); } $test = 'hello'; abc(&$test); $test = 'bye'; abc(); output: string(5) "hello" NULL should be: string(5) "hello" string(3) "bye" Was this done for security reasons? or is it just a PHP limitation? Although less convenient, this bug can be worked around like so: function abc($v=0){ static $r; if($v) $r = $v; var_dump($r['test']); } $test = 'hello'; abc(array('test'=>&$test)); $test = 'bye'; abc(); output: string(5) "hello" string(3) "bye" So why won't static variable retain a direct reference??
  7. [quote author=thorpe link=topic=124065.msg513664#msg513664 date=1169773177] You cant catch parse errors. In fact you can't catch php generated errors. The best you could do would be..... [code] <?php try {   if (!@eval('will cause error')) {     throw new exception('unknown error');   } } catch (Exception $e) {   echo 'Caught exception: '.$e->getMessage()."\n"; } ?> [/code] Which I'm sure is not really what you want to hear. Ive always thought the same myself, not being able to catch php's exceptions.... then whats the point? [/quote] Thanks Thorpe Yea the PHP try/catch system is weak
  8. [quote author=konnwat link=topic=124065.msg513580#msg513580 date=1169764776] [code]<?php try { eval('will cause error'); } catch (Exception $e) {   echo 'Caught exception: '.$e->getMessage()."\n"; } ?>[/code] try that ^^ [/quote] yea, that doesn't work. it won't execute anything inside the catch block, but still raises the parse error, i want to catch that error. im using php 5.1.4
  9. in Javascript one can easily do the following: <script type="text/javascript"> try { eval('will cause error'); } catch(e) { alert(e); } </script> in PHP the try catch system is only for errors thrown by your code, seems like I can't catch errors thrown by PHP. <?php try { eval('will cause error'); } catch (Exception $e) {   echo 'Caught exception: ',  $e->getMessage(), "\n"; } ?> Sadly that wont work, really limits the whole try/catch concept. Any other ways I can achieve a Javascript like functionality?
  10. when you include/require from inside a function (or any nested structure for that matter) does the included file context start at the top level, or as a continuation of the structure where it was included? From what i can tell they start at the top level. Can someone just confirm that for me. Thanks
  11. I ran this string as a shell command: $cmd = 'ps -o%mem,rss,pid | grep ' . getmypid(); It shows the mem usage. I ran it in a bare script and it showed it's using just over 7000 kb of mem, 0.7% or total memory. I guess the server has 1gig memory. This seemed like a large chunk of memory for a bare bone script to be using, so I made a huge array(range(1, 10000)) to see if the mem usage jumped, just to make sure this was the right process. It spiked up by 800kb. The question I have... isn't 7 megs rather much for a bare script process to take up?? How does php run each script? Does it start them as their own process, or as a thread from the main php process, or does what I just typed make me sound like a total noob. Thanks for any insight, feel free to include extra details, nerd talk is my friend.
  12. my concern with the solution you presented was the needless memory usage it comes with (although it's better than scandir, according to this http://bugs.php.net/bug.php?id=31515) Thanks though. I'll have to devise some sort of indexing scheme or something.
  13. I've read all the typical mumbo jumbo on directory scanning and counting content, but it seems like the more practical stuff is missing. 1: The rewinddir function is nice... but is there a fast way to arbitrarily jump dir position? (like what fseek is to files) Would this somehow be possible with the resource context param?     2: Shouldn't the Count of contents in a directry be kept as a value by the system? Would save time otherwise wasted on iterating through. 3: Hypothetically, if there are millions of files in a directory, are you screwed? Thanks for any help.
  14. Is there any guarantee in the order in which php scripts run. I know if I tell the script to sleep, or do a database query, other scripts will still run unbothered. Is each script technically a seperate process? Is it possible that the system may decide to put a script on pause for a bit and execute a section of another script before coming back to the first one? Thanks
×
×
  • 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.