{"id":16865,"date":"2015-08-29T05:01:16","date_gmt":"2015-08-28T19:01:16","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=16865"},"modified":"2015-08-29T09:18:55","modified_gmt":"2015-08-28T23:18:55","slug":"php-desktop-command-line-follow-up-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/php-desktop-command-line-follow-up-tutorial\/","title":{"rendered":"PHP Desktop Command Line Follow Up Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/php_substitute_desktop.gif\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"PHP Desktop Command Line Follow Up Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/php_substitute_desktop.gif\" title=\"PHP Desktop Command Line Follow Up Tutorial\" id='myiis' onmouseover=\" this.src=this.src.replace('.gif','.xpng').replace('.png','.xgif').replace('.x','.'); \"   \/><\/a><p class=\"wp-caption-text\">PHP Desktop Command Line Follow Up Tutorial<\/p><\/div>\n<p>Yesterday we started on some PHP desktop tutorials for a XML Chapter Changes via the Substitution of Strings desktop job when we presented <a target=_blank title='PHP Desktop Command Line Primer Tutorial' href='#pdclpt'>PHP Desktop Command Line Primer Tutorial<\/a> as shown below.<\/p>\n<p>Of the three web modes of use today&#8217;s improvement work is &#8230;<\/p>\n<ul>\n<li>web browsing (or &#8220;surfing the net&#8221;) &#8230; we add an HTML form as <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/php_substitute_desktop.gif\" title='Tutorial picture'>pictured<\/a> &#8230; that one is relatively easy<\/li>\n<li>command line usage &#8230; we leave it as is, interactively asking the user for information &#8230; though you could approach this with a menu system perhaps<\/li>\n<li>curl on the command line &#8230; now this is more problematic because of the difficulty with interactive input and curl usage &#8230; so we &#8230;\n<ol>\n<li>in the first instance expect the user to type <br \/>&#8220;curl http:\/\/www.rjmprogramming.com.au\/PHP\/renumber_more.php&#8221;<br \/> at the command line to start off<\/li>\n<li>the user sees on the command line the output of the underlying HTML as if web browsing, but it contains a more complex <br \/>&#8220;curl http:\/\/www.rjmprogramming.com.au\/PHP\/renumber_more.php?curlget=%7Cfilespec%3DCOM_.IOVBK%2F%2A.xml%7Cynftt%3D%23%40%21%40%23%7Cprefix1%3Dolink%3E%7Cprefix2%3Dolink+targetptr%3D%22start%22%3E%7Cprefix3%3Dolink+targetptr%3D%22end%22%3E%7Cprefix4%3Dlabel%3D%22%5B%7Cprefix5%3Dlabel%3D%22%7Cprefix6%3DCOMM.IOVBK%7ECH.%7Clookup%3D%5B30.%2C%5B29.%7C%5B32.%2C%5B30.%7C%5B33.%2C%5B31.%7C%5B34.%2C%5B32.%7C%5B35.%2C%5B33.%7C%5B36.%2C%5B34.%7C%5B37.%2C%5B35.%7C%5B38.%2C%5B36.%7C%5B39.%2C%5B37.%7C%5B40.%2C%5B38.%7C%5B41.%2C%5B39.%7C%5B42.%2C%5B40.%7C%5B43.%2C%5B41.%7C%5B46.%2C%5B42.%7C%5B47.%2C%5B43.%7C%5B48.%2C%5B44.%7C%5B49.%2C%5B45.%7C%5B50.%2C%5B46.%7C%5B50A.%2C%5B47.%7C%5B52.%2C%5B48.%7C%5B53.%2C%5B49.%7C%5B54.%2C%5B50.%7C%5B55.%2C%5B51.%7C%5B56.%2C%5B52.%7C%5B59.%2C%5B53.%7C%5B60.%2C%5B54.%7C%5B61.%2C%5B55.&#8221;<br \/> type of suggestion command line idea which the user can copy and adjust (in that encoded way, unfortunately, using vertical bar | as the major delimiter) into another copy buffer<\/li>\n<li>the user pastes that adjusted new complex curl command onto the command line, to complete the task<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<p>All in all, we do not recommend curl usage, for this job!<\/li>\n<p>Here is that PHP code &#8230;<\/p>\n<ul>\n<li><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/renumber_more.php--GETME\" title='renumber_more.php'>renumber_more.php&#8211;GETME<\/a> &#8230; for desktop prompted interactive use and\/or curl and\/or web application (with HTML form) usage, and so it is meaningful, now, to offer a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/renumber_more.php\" title='live run'>live run<\/a> link<\/li>\n<li><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/renumber_more.php-GETME\" title='renumber_more.php'>renumber_more.php-GETME<\/a> &#8230; for desktop prompted interactive use and\/or web application (defaults only) usage<\/li>\n<li><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/renumber_more.php--GETME\" title='renumber_more.php'>Changes here regarding this tutorial<\/a><\/li>\n<li><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/renumber_more.php_GETME\" title='renumber_more.php'>renumber_more.php_GETME<\/a> &#8230; web application (defaults only, and &#8220;hardcoded&#8221;) usage<\/li>\n<li><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/renumber_more.php-GETME\" title='renumber_more.php'>Changes as for tutorial below<\/a><\/li>\n<\/ul>\n<hr>\n<p id='pdclpt'>Previous relevant <a target=_blank title='PHP Desktop Command Line Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/php-desktop-command-line-primer-tutorial\/'>PHP Desktop Command Line Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/php_substitute_desktop.jpg\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"PHP Desktop Command Line Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/php_substitute_desktop.jpg\" title=\"PHP Desktop Command Line Primer Tutorial\"    \/><\/a><p class=\"wp-caption-text\">PHP Desktop Command Line Primer Tutorial<\/p><\/div>\n<p>Sometimes you have desktop program requirements involving files and the operating system.  If the job is quite large you&#8217;d probably want to involve one of the well known IDEs like Xcode for Mac or Visual Studio for Windows or perhaps NetBeans or Code:Block and they could provide solutions in a whole gamut of compilable programming languages such as C++, C#, VB.Net, C or Java, just to name a few.<\/p>\n<p>To avoid some of this bother for smaller jobs we recommend, in Windows, Digital Mars C (or D), and we&#8217;ve talked about that <a target=_blank title='Digital Mars blog posts' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=digital-mars'>here<\/a>.<\/p>\n<p>Today we start on a short journey to show you that PHP at the command line, with command line curl, or as a web application (especially with a local MAMP web server on Mac or EasyPHP web server on Windows) can be another option.  Do you remember <a target=_blank title='PHP Modes of Use File Traverse Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/php-modes-of-use-file-traverse-tutorial\/'>PHP Modes of Use File Traverse Tutorial<\/a>?<\/p>\n<p>The job we show today is an XML Chapter Changes via the Substitution of Strings desktop job.   In this job we have &#8230;<\/p>\n<ol>\n<li>a filespec, on the desktop (or USB) of input data files<\/li>\n<li>a mapping string file (or the data of) to map the chapter information, only, that is of interest<\/li>\n<\/ol>\n<p> &#8230; from that we start with a quick MAMP web application solution &#8230; we&#8217;ll show you here as renumber_more.php_GETME full of hardcodings and assumptions.<\/p>\n<p>We rid the code of many hardcodings to genericize it considerably, and we show you some of that journey via renumber_more.php-GETME where we introduced some PHP command line interactive usage where we got help from <a target=_blank title='Useful link' href='http:\/\/stackoverflow.com\/questions\/2929629\/how-do-i-write-a-command-line-interactive-php-script'>this link<\/a> (thanks).  This interactivity only happens in the PHP usage from the command line, and to test for that we &#8230;<\/p>\n<p><code><br \/>\n if (isset($argv[0])) {  \/\/ PHP command line specific interactive input code below ...<br \/>\n  \/\/<br \/>\n  \/\/ PHP command line specific interactive input code<br \/>\n  \/\/<br \/>\n }  \/\/ ... end of PHP command line specific interactive input code<br \/>\n<\/code><\/p>\n<p>Here is that PHP code &#8230;<\/p>\n<ul>\n<li><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/renumber_more.php-GETME\" title='renumber_more.php'>renumber_more.php-GETME<\/a> &#8230; for desktop prompted interactive use and\/or web application (defaults only) usage<\/li>\n<li><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/renumber_more.php_GETME\" title='renumber_more.php'>renumber_more.php_GETME<\/a> &#8230; web application (defaults only, and &#8220;hardcoded&#8221;) usage<\/li>\n<li><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/renumber_more.php-GETME\" title='renumber_more.php'>Changes<\/a><\/li>\n<\/ul>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d16839' onclick='var dv=document.getElementById(\"d16839\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/?tag=command-line\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d16839' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d16865' onclick='var dv=document.getElementById(\"d16865\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/?tag=curl\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d16865' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Yesterday we started on some PHP desktop tutorials for a XML Chapter Changes via the Substitution of Strings desktop job when we presented PHP Desktop Command Line Primer Tutorial as shown below. Of the three web modes of use today&#8217;s &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/php-desktop-command-line-follow-up-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,29,33,37],"tags":[234,284,319,372,617,707,714,744,885,932,997,1252,1319,1402,1480],"class_list":["post-16865","post","type-post","status-publish","format-standard","hentry","category-elearning","category-operating-system","category-software","category-tutorials","tag-command-line","tag-curl","tag-desktop","tag-easyphp","tag-interactive","tag-linux","tag-local-web-server","tag-mamp","tag-operating-system-2","tag-php","tag-programming","tag-terminal","tag-tutorial","tag-web-application","tag-xml"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/16865"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=16865"}],"version-history":[{"count":7,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/16865\/revisions"}],"predecessor-version":[{"id":16879,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/16865\/revisions\/16879"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=16865"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=16865"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=16865"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}