Jump to content

bgsomers

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

bgsomers's Achievements

Member

Member (2/5)

0

Reputation

  1. I have a routine that scans guest-book entries for objectionable words or terms, using the function strpos: if strpos($entry, 'word1') == TRUE or strpos($entry, 'word2') == TRUE ... I want to create "strposplus", which will use strpos in this way, but when a word is found, will write that word to a file, along with the entry itself. if strposplus($entry, 'word1') == TRUE or strposplus($entry, 'word2') == TRUE ... Does the argument 'word1' get a name by which it can be referenced? Or must I assign it to a named variable before my call to strposplus? Bruce
  2. class CInput extends CTools { # bl-s01   function CInput($emotion = "no")   { # bl-s02     $this->CTools($emotion);     } # bl-e02 ... CTools is the primary class in this application. What does $this->CTools($emotion); do? Bruce
  3. Do I understand correctly, that an included file in inserted into the including file when it is loaded into memory, at the point where the include() instruction is found? But that its code is not executed until the flow of control reaches the include() instruction. Is that the way it is carried out? Bruce
  4. Thank you. Then $this->xxxx is applicable only within the definition of a class, to refer to a variable xxxx defined therein? Outside of such a class definition, the name of an object in which the variable is defined is (always) needed?
  5. In the following routine, $example->items leads to the value "g-items" as expected. But why does $this->items lead to nothing? Is there some way in PHP, to display the contents of a non-printable variable in octal or hexadecimal form? Bruce [code]<?php class Cart {   var $items = "g-item";  // Items in our shopping cart     // Add $num articles of $artnr to the cart   function add_item($artnr, $num) {       $this->items[$artnr] += $num;   }   // Take $num articles of $artnr out of the cart   function remove_item($artnr, $num) {       if ($this->items[$artnr] > $num) {           $this->items[$artnr] -= $num;           return true;       } elseif ($this->items[$artnr] == $num) {           unset($this->items[$artnr]);           return true;       } else {           return false;       }   } } $example = new Cart(); echo '$example->items yields:  '.$example->items.'<br/>'; echo '$this->items yields nothing:  '.$this->items.'<br/>'; echo '$items yields nothing:  '.$items.'<br/>'; print_r($example); ?> [/code]
  6. Could some kind soul explain in words, the effect of the operator  ->  in the following? What does it 'achieve'? Is  ->  called an operator? $input = new CInput(); $input->Formular_Show(0, $newname, $newmail, $newurl, $newicq, $newaim, $newtext); Is there documentation somewhere in which this can be sought? Many thanks,  Bruce
  7. [quote]I'm not sure what you mean by processor code[/url], do you want to view the contents of the .dat file? If so, use fread(). [/quote] No - I'd like to see the machine/processor code that is generated from my source code, to see what conditional jumps and the like are generated. I know - I come from another, non-PC, worldl! Bruce
  8. With the instruction $input = fopen("../".$datapath."/wordfilter.dat", "r") or exit("Can't open wordfilter.dat for reading!"); I assume that fopen() ist executed, and if it returns TRUE, then execution is ended. If it returns FALSE, then exit() is executed. Is there some way to inspect the processor code actually produced, and not just the source code? Bruce
  9. ---You are not changing the value of buffer! trim() returns a trimmed value, but you are not assigning it to anything or using it. Great Scott! Thank you very much. Bruce
  10. The code echo "buffer--|".$buffer."|--end<br/>"; trim($buffer, " "); echo "trimmed buffer--|".$buffer."|--end<br/>"; rtrim($buffer, " "); echo "rtrimmed buffer--|".$buffer."|--end<br/>"; leads to the output buffer--|term1 10 |--end trimmed buffer--|term1 10 |--end rtrimmed buffer--|term1 10 |--end The descriptions of trim() and rtrim() do not suggest that they will leave a trailing space in the string processed. How should one understand this situation? Bruce (Sorry - I can't see what is limiting the length of the code lines above.)
  11. What on earth can I be doing wrong so that  \n in an echo instruction produces no line breaks? The \n are being processed as they do not appear in the output, but there are no line breaks. Bruce
  12. I run the following [code]session_start(); # create session to be resumed in file input.php $_SESSION["StartTime"] = time(); # if(isset($_SESSION["StartTime"])) { echo 's'; } [/code] and the display alway contains a small 's', indicating that $_SESSION["StartTime"] has been stored. Later in the processing, I have [code]session_start(); # resume session created in file new.html $mintime = 15; $check = time(); $duration = ($check - $_SESSION["StartTime"]); $admin01 = 'duration was: '.$duration; $admin02 = 'check time was: '.$check; $admin03 = 'start time if retrieved: '.$_SESSION; if (!empty($_SESSION)) { $admin04 = print_r($_SESSION,true);   } else { $admin04 = 'the session variable $_SESSION has not been retrieved ';   } [/code] Less than half the time, this leads to - duration was: 2 - check time was: 1154188904 - start time if retrieved: Array - Array (     [StartTime] => 1154188902 ) indicating that $_SESSION["StartTime"] has been retrieved, and all is well. But more than half of the time, it leads to - duration was: 1154186069 - check time was: 1154186069 - start time if retrieved: Array - the session variable $_SESSION has not been retrieved indicating that the array element $_SESSION["StartTime"] was empty. How can this data be passed part of the time, but not all of the time? Bruce
  13. Thanks -- king arthur: Are you calling session_start() twice somehow? Or unsetting the $_SESSION variable somewhere? Yes - called once at the start of each processing of the session (in different files). The manual says that it's necessary to resume the session. Thanks -- dark dude: ^^^ You're not signing now as a variable at the top: Oh dear - that was a editing error.  "now" is written $now" in the code. Sorry. "signing as a variable"? I never declare variables at the outset in PH
  14. Thank you Ken for that useful assistance. I don't believe I could have found it on my own. I fear that interest in my problem is waning, but I have some more information, which hasn't cleared up a lot - not for me. at least. My code (in file new.html.inc) [code]session_start(); $_SESSION["StartTime"] = time(); if(isset($_SESSION["StartTime"])) { echo 's'; }[/code] reproducibly displays a character s, indicating that $_SESSION has been created. The code (in file input.php) [code]session_start(); $mintime = 15; $check = time(); $duration = ($check - $_SESSION["StartTime"]); $admin01 = 'duration was '.$duration; $admin02 = 'check time was '.$check; $admin03 = 'start time was '.$_SESSION["StartTime"]; $admin04 = ' '; if (!empty($_SESSION)) $admin04 = print_r($_SESSION,true);[/code] later in the processing, often shows that $_SESSION exists: date=27.07.2006 19:34 - duration was 1 - check time was 1154021699 - start time was 1154021698 - Array (     [StartTime] => 1154021698 ) but not always: date=27.07.2006 19:38 - duration was 1154021938 - check time was 1154021938 - start time was - So it has the appearance that the previous session is not always being resumed. What can be the cause of that? Working only now and then is actually worse than not working at all.
  15. Is there a way to display the entire contents of an array whose structure is not known? $_SESSION for example?
×
×
  • 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.