Jump to content

iwato

Members
  • Content Count

    1,506
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by iwato

  1. My search for shell expressions took me down a myriad of paths with a variety of outcomes that I did not understand very well. It is the reason that I finally surrendered and asked for help.By the way, I removed the extra characters in my code and everything worked fine. Perhaps the W3 School's entry for fnmatch() should be modified, as it is misleading in its present form.Also, thank you for the link to shell expressions. It was very helpful.Roddy
  2. QUESTION ONE:PART A: What is the difference between shell and regular expression syntax? For example, are their times when one is preferred over the other, even though both are applicable? Or, are they mutually exclusive? Can they used together?PART B: Is the regular expression syntax standard across platforms and applications? For example, can I depend on my knowledge of regular expression syntax in Javascript and ActionScript when working with PHP? PART C: How about shell syntax? Is it just as flexible?PART D: How does one go about learning shell syntax?QUESTION TWO: Why do the following two blocks of code both fail?BACKGROUNDOne was obtained from the W3 Schools website and one from the PHP website. Each set of code was run separately on a Mac OS 10.5.8 with PHP 5.0+. Research on the net reveals that the Mac OS is probably POSIX conformant. I have adjusted the code syntax so that it would at least process. Yeah, I know they are operationally identical, but the PHP website example is hopelessly flawed.W3 Schools $txt = "My car is darkgrey...";if (fnmatch("*gr[ae]y",$txt)) { echo "some form of gray ..."; } PHP Website $color = "My car is darkgrey...";if (fnmatch("*gr[ae]y", $color)) { echo "some form of gray ...";} Roddy
  3. iwato

    The sleep( ) Function

    Now that I know that the term write buffer is sometimes confused with that of the output buffer, and that the ob_implicit_flush() function operates on the output buffer, why is it that the following two blocks of code produce identical results:CODE BLOCK ONE:ob_implicit_flush(1);echo "Start time: " . date("h:i:s") . "<br />";sleep(3);echo "End time: " . date("h:i:s"); CODE BLOCK TWO: echo "Start time: " . date('h:i:s') . "<br /><br />";flush();sleep(3);echo "End time: " . date('h:i:s'); Is it because both the flush() and ob_implicit_flush() functions both operate on the output buffer?If so, what is an example of a function that operates on a file buffer? Would it be the clearstatcache() function?Roddy
  4. iwato

    The sleep( ) Function

    QUESTION ONE:I obtained the notion of a write buffer from the functional description of the flush() function on the PHP website. Do the words output buffer and file buffer, as you have used them, correspond to the ob_flush() and flush(), respectively? See below. QUESTION TWO: When I apply the ob_implicit_flush() and set the flag to TRUE, does it inhibit both of the aforementioned buffers or only the output buffer?NOTE: None of my experimentation with buffer flushing has included a file resource that I have created.Roddy
  5. iwato

    The sleep( ) Function

    With all of the caveats attached to the PHP website about the flush( ) function, your point is well made.I have even discovered a new one that is not listed. The flush( ) function only flushes to the last completed HTML tag.Roddy
  6. iwato

    The sleep( ) Function

    I have experimented with the sleep( ), flush( ), and op_implicit_flush( ) functions, and they all perform as expected. Although encouraging, my expectations were met under the assumption that the write buffer is a subset of the output buffer. Is this true? Roddy
  7. iwato

    The sleep( ) Function

    QUESTION: Why is the first time not echoed before the 10 seconds have elapsed?BACKGROUND: After 10 seconds both echoed statements appear indicating a 10 second difference. <?php echo date('h:i:s') . "<br />"; sleep(10); echo date('h:i:s'); ?> SOURCE: This is code taken from the W3Schools website.Roddy
  8. iwato

    Understanding Resources

    I found this very useful and quite enjoyed what led up to it. This left me rolling on the floor. Many thanks for your input!Roddy
  9. iwato

    Understanding Resources

    Yes, it is true one can get carried away in talking about what one should be doing, but I find knowing the vocabulary of the discussion helps enormously in reducing the chatter. Agreed?Roddy
  10. iwato

    Understanding Resources

    It sure matters to me. I surely cannot know it all before I begin, but it surely helps to have a good overview before I begin to build. That does mean that I have to know everything about swimming before I get in the water, but I do have to know enough so as not to drown should I find myself slipping into the deep end.Roddy
  11. This is the error that I found in the MAMP-Pro generated error log.The file TMP3B0QR6NEX.php is test file produced by Safari when I run my test server in Dreamweaver.[01-Apr-2010 14:32:57] PHP Fatal error: Call to undefined function fopen() in /Applications/MAMP/htdocs/php-practice/functions/miscellaneous/exit/TMP3B0QR6NEX.php on line 38.Roddy
  12. Could it be that my PHP initialization is controlled by my installation host? When I try to contact e-Living theThis what I found inside when I looked. Everything expression containing the word MAMP was highlighted in red, so it made it easy to find. error_reporting = MAMP_error_reporting_MAMPdisplay_errors = MAMP_display_errors_MAMPdisplay_startup_errors = MAMP_display_startup_errors_MAMPlog_errors = MAMP_php_log_errors_MAMPerror_log = "MAMP_php_error_log_MAMP"extension_dir = "MAMP_extension_dir_MAMP"; ExtensionsMAMP_apc_MAMPextension=imap.soextension=gettext.soextension=mcrypt.soextension=yaz.soextension=pgsql.soextension=pdo_pgsql.soextension=pdo_mysql.soMAMP_eAccelerator_MAMP eaccelerator.shm_size="16" eaccelerator.cache_dir="/Applications/MAMP/tmp/eaccelerator" eaccelerator.enable="1" eaccelerator.optimizer="1" eaccelerator.check_mtime="1" eaccelerator.debug="0" eaccelerator.filter="" eaccelerator.shm_max="0" eaccelerator.shm_ttl="0" eaccelerator.shm_prune_period="0" eaccelerator.shm_only="0" eaccelerator.compress="1" eaccelerator.compress_level="9" eaccelerator.allowed_admin_path="/Library/Application Support/living-e/MAMP PRO/mamp"[xcache-common]; install as zend extension (recommended), normally "$extension_dir/xcache.so"MAMP_XCache_MAMP[Zend]zend_optimizer.optimization_level=15MAMP_zend_optimizer_MAMP I have sent a request to MAMP Pro -- my installation host -- to explain the presence of this code, but they have not yet responded.Also, I have a slightly different, but related question: Is it possible for the unencoded HTML of a PHP file to display even though the PHP encoded portion of the code fails?Roddy
  13. iwato

    Understanding Resources

    If I am to take credit for this remark, then I should apologize. Please consider it a typo.Based upon what you have written below you reject the notion that resources are a kind of event object that transmit information, rather you see them as persistent or temporary objects that can be repeatedly called by other objects to perform a highly specific set of tasks. But then, how are they any different from class objects (instances) created to perform a particular set of tasks? In short, what sets them apart? Their structure? The tasks that they perform? Their accessibility? Roddy
  14. iwato

    PHP Tut on W3Schools

    I do not want to detract from the original authors intent, but just wanted to say thanks for introducing me to the section on Classes and Objects, it provides much better explanations about how PHP works than do the brief definitions provided for individual functions.Roddy
  15. I am expecting an echoed message that tells me whether or not a resource was created for the file that I just opened.Roddy
  16. iwato

    Understanding Resources

    Great! I now have a much better feel for what a resource is.Good team work! Much appreciated.Roddy
  17. iwato

    Understanding Resources

    So, they are a kind of event object (ActionScript) -- an object created by one object to carry information to another object. In ActionScript such objects usually contain properties that when received determine the behavior of the recipient object. By way of example, when I apply the fopen( ) function to a file, the fopen( ) function creates an object (a resource) that contains information about the file just acted upon by the fopen( ) function. When I assign the return value of the fopen( ) function to a variable, I am in effect creating a named reference for that object that I can then pass on to other functions as a parameter for further processing. Is this correct?Roddy
  18. It is good to know that the lock disappears when the file is closed. I will have to explore the sleep() function.This said, whether the second echo statement is proper or not, the second experiment fails. Could it be a problem with permissions again. I thought I had resolved that problem.Roddy
  19. Not really. It was just a typo. I copy and paste via a format neutralizer.Whether the echo command is present or not, it fails.Roddy
  20. iwato

    Understanding Resources

    There is no confusion here. I am perfectly satisfied that I do not know what happens inside a built-in PHP method (function), so long as I know what comes out when I put something in. Obviously, what comes out is not always what I expect, because I do not understand what is going on inside. Unfortunately, at my current level of PHP competence I am still unable to explore the properties and methods of a built-in PHP function with any degree of efficiency.Am I in error to believe that resources are not objects with properties and functions shared by all resources? Are you familiar with ActionScript? Perhaps you could explain with terminology that I am more familiar like listener objects, event-handlers, event objects, classes, and objects created from classes, etc. Because the value of the reference variable to which it is assigned is still present after the resource has been closed.Roddy
  21. QUESTION: What is a good explanation for Experiment 2's failure to generate a statement?BACKGROUND: The following is modified code obtained from an example given on the PHP website. My goal was to understand the use of the flock() function and its parameters. Two experiments in two different PHP files were run. Their results are provided below.experiment1.php: I can run this experiment as often as I like, and the statement "Unable to obtain lock" is never echoed. <?php $file = "../copy/nonPHP_file.txt"; echo "The original file is " . filesize($file) . " bytes large."; clearstatcache(); $openedFile = fopen($file, 'r+'); if(!flock($openedFile, LOCK_EX | LOCK_NB)) { echo 'Unable to obtain lock'; exit(-1); } fclose($openedFile);?> experiment2.php: Although the PHP run is successful, the experiment fails to produce either of the two hoped for echoed strings. <?php $file = "../../filesystem/copy/nonPHP_file.txt"; $openedFile = fopen($file, "a+"); if (!$openedFile) { echo "The file " . $file . " failed to open. <br />"; } else { "The file " . $file . " was successfully opened. <br />"; }?> Roddy
  22. iwato

    Understanding Resources

    COMMENT: I am only interested in black boxes whose output can be well understood. I need to know what is going to come out when I put something in. I am sure that you can appreciate my concern.QUESTION: Are you saying that a resource is an object that is constructed from the contents of a file, but whose methods and properties are entirely different from those of the file from which it was constructed? If this is true, than I can more easily understand. The word "usually" is not well understood in this context. I can understand that an object exists, but is not available until some action is taken on it. In contrast, I cannot understand that an object simultaneously exists and does not exist. Please clarify. Are you saying that more than one method (function) can point to the same object (resource) at the same time, but that neither method can act on the object while the other method is acting on it?Roddy
  23. This is a several part question whose parts relate to the same notion -- the nature of resources. The order in which the questions are posed is important. These questions are based on many minutes of experimentation with various conclusive and inconclusive results.QUESTION ONE: Is it reasonable to assume that a resource is a kind of file version whose content does not change despite changes made to the file through other resources?QUESTION TWO: If the answer to Question One is yes, then is it possible to access a resource after it has been closed?QUESTION THREE: If the response to Question Two is no, why is the pointer contained in the reference variable to a resource retained after the resource has been closed?QUESTION FOUR: If it possible to access the contents of different open resources to the same file , how is it done?Roddy
  24. iwato

    How to learn php.

    The PHP Manual found on the PHP website makes for a great supplementary asset. It has one very important drawback; however, there is no PDF compliment that you can mark up while you learn. In order to overcome this handicap I have developed a file system to house php files for experimentation on my local test server. In these files I can make all the notes I want and have a record of everything that I have studied.Roddy
×
×
  • Create New...