<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:foaf="https://xmlns.com/foaf/0.1/" xmlns:og="https://ogp.me/ns#" xmlns:rdfs="https://www.w3.org/2000/01/rdf-schema#" xmlns:schema="https://schema.org/" xmlns:sioc="https://rdfs.org/sioc/ns#" xmlns:sioct="https://rdfs.org/sioc/types#" xmlns:skos="https://www.w3.org/2004/02/skos/core#" xmlns:xsd="https://www.w3.org/2001/XMLSchema#" version="2.0" xml:base="https://www.linuxjournal.com/tag/php">
  <channel>
    <title>PHP</title>
    <link>https://www.linuxjournal.com/tag/php</link>
    <description/>
    <language>en</language>
    
    <item>
  <title>Building a March Madness Bracket in PHP</title>
  <link>https://www.linuxjournal.com/content/building-march-madness-bracket-php-0</link>
  <description>  &lt;div data-history-node-id="1339718" class="layout layout--onecol"&gt;
    &lt;div class="layout__region layout__region--content"&gt;
      
            &lt;div class="field field--name-field-node-image field--type-image field--label-hidden field--item"&gt;  &lt;img src="https://www.linuxjournal.com/sites/default/files/nodeimage/story/bigstock-Basketball-Ball-Over-White-Bac-156016058_0.jpg" width="450" height="450" alt="""" typeof="foaf:Image" class="img-responsive" /&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-author field--type-ds field--label-hidden field--item"&gt;by &lt;a title="View user profile." href="https://www.linuxjournal.com/users/jim-hall" lang="" about="https://www.linuxjournal.com/users/jim-hall" typeof="schema:Person" property="schema:name" datatype="" xml:lang=""&gt;Jim Hall&lt;/a&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"&gt;&lt;p&gt;&lt;em&gt;Jim Hall takes his March Madness script to the next level.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;
Every year in March, my office closely follows the NCAA college basketball
tournament, also known as March Madness. You can print out a bracket
and make your own predictions as to which team will win at each round. Several of my
co-workers take this somewhat seriously, and they always print out their
brackets and tack them to their work cubes for all to see. Generally, the winner
buys a pizza lunch for the others who played.
&lt;/p&gt;&lt;p&gt;

&lt;/p&gt;&lt;p&gt;
I like to join in, but unfortunately, I lack one thing to participate
effectively: I don't really follow basketball.
&lt;/p&gt;

&lt;p&gt;
But, I don't like to miss out on March Madness, so a few years ago, I
created a Bash script to help me fill out my March Madness bracket. This
worked pretty well. I ran the script, and then I used the results to fill out
my March Madness bracket.
&lt;/p&gt;
&lt;p&gt;See my previous two articles for more info on the script:
&lt;a href="https://www.linuxjournal.com/content/bash-shell-script-building-better-march-madness-bracket"&gt;Bash
Shell Script: Building a Better March Madness Bracket&lt;/a&gt; (2017) and
&lt;a href="https://www.linuxjournal.com/content/bash-shell-script-building-your-march-madness-bracket"&gt;Bash
Shell Script: Building Your March Madness Bracket&lt;/a&gt; (2016).
&lt;/p&gt;

&lt;p&gt;
This year, I decided to take things to the next level. Rather than run a
Bash script, why not create a web page that automatically fills in the winners
for each round? That way I won't really even need to fill out a March Madness
bracket; I can just print out the results from my web page.
&lt;/p&gt;

&lt;h3&gt;
Guessing the Winners of Each Game&lt;/h3&gt;

&lt;p&gt;
In the NCAA college basketball tournament, 64 teams from four regions compete
in a series of single-elimination games. "Single-elimination" means
that after each round, the winning teams move on to the next round; the losing
teams are out. The NCAA seeds the first round with the top teams from each
region and assigns a ranking value to each team. Usually, the higher-rated
teams (1–8) fare better than the lower-rated teams (9–16).
&lt;/p&gt;

&lt;p&gt;
You can use this "rank" value to guess who might win or lose an
individual contest. A rank 1 team should perform better than a rank 16 team,
but a rank 8 team should perform about the same as a rank 9 team. I found that
the best simulation of a game's outcome is to create a virtual
"die" that I "roll" to determine the winner. The die has faces
relative to the chance of each team to win, as represented in this simple
algorithm to generate a custom die:
&lt;/p&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-link field--type-ds field--label-hidden field--item"&gt;  &lt;a href="https://www.linuxjournal.com/content/building-march-madness-bracket-php-0" hreflang="en"&gt;Go to Full Article&lt;/a&gt;
&lt;/div&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;

</description>
  <pubDate>Wed, 07 Mar 2018 18:24:59 +0000</pubDate>
    <dc:creator>Jim Hall</dc:creator>
    <guid isPermaLink="false">1339718 at https://www.linuxjournal.com</guid>
    </item>
<item>
  <title>Rogue Wave Software's Zend Studio</title>
  <link>https://www.linuxjournal.com/content/rogue-wave-softwares-zend-studio</link>
  <description>  &lt;div data-history-node-id="1339446" class="layout layout--onecol"&gt;
    &lt;div class="layout__region layout__region--content"&gt;
      
            &lt;div class="field field--name-field-node-image field--type-image field--label-hidden field--item"&gt;  &lt;img src="https://www.linuxjournal.com/sites/default/files/nodeimage/story/12202f4.png" width="800" height="518" alt="" typeof="foaf:Image" class="img-responsive" /&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-author field--type-ds field--label-hidden field--item"&gt;by &lt;a title="View user profile." href="https://www.linuxjournal.com/users/james-gray" lang="" about="https://www.linuxjournal.com/users/james-gray" typeof="schema:Person" property="schema:name" datatype="" xml:lang=""&gt;James Gray&lt;/a&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"&gt;&lt;p&gt;
The quick pitch for Rogue Wave Software's &lt;a href="https://www.zend.com"&gt;Zend&lt;/a&gt; Studio, recently updated to
version 13.6, is "the PHP IDE for smarter development". Zend Studio
13.6, says Rogue Wave, offers 3X faster performance in indexing, validation
and searching of PHP code, and it allows users to code faster, debug more easily and
leverage the massive performance gains in PHP 7. It is the next-generation PHP
IDE designed to create high-quality PHP apps while boosting developer
productivity. The platform automatically scales according to the DPI settings
of the underlying operating system and supports HiDPI monitors. 
&lt;/p&gt;

&lt;p&gt;
The main focus
in this new release is the support for PHP 7.1, which contains useful language
improvements like nullable types, void return type and catching multiple
exception types. Additional feature improvements relate to Composer and
JavaScript tooling, and Zend Studio 13.6 takes advantage of the tern.js
intellisense engine, providing intellisense for a long list of JavaScript
frameworks, namely AngularJS, Closure, CordovaJS, Dojo, ExtJS, jQuery and
Node.js. 
&lt;/p&gt;

&lt;p&gt;
Finally, the release comes with the latest and greatest release of the
Eclipse Platform, Neon.3, which brings with it its own slew of improvements.
&lt;/p&gt;
&lt;img src="https://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1000009/12202f4.png" alt="" title="" class="imagecache-large-550px-centered" /&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-link field--type-ds field--label-hidden field--item"&gt;  &lt;a href="https://www.linuxjournal.com/content/rogue-wave-softwares-zend-studio" hreflang="und"&gt;Go to Full Article&lt;/a&gt;
&lt;/div&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;

</description>
  <pubDate>Mon, 24 Jul 2017 11:52:35 +0000</pubDate>
    <dc:creator>James Gray</dc:creator>
    <guid isPermaLink="false">1339446 at https://www.linuxjournal.com</guid>
    </item>
<item>
  <title>The Family Dashboard</title>
  <link>https://www.linuxjournal.com/content/family-dashboard</link>
  <description>  &lt;div data-history-node-id="1339395" class="layout layout--onecol"&gt;
    &lt;div class="layout__region layout__region--content"&gt;
      
            &lt;div class="field field--name-field-node-image field--type-image field--label-hidden field--item"&gt;  &lt;img src="https://www.linuxjournal.com/sites/default/files/nodeimage/story/12115f2.jpg" width="750" height="592" alt="" typeof="foaf:Image" class="img-responsive" /&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-author field--type-ds field--label-hidden field--item"&gt;by &lt;a title="View user profile." href="https://www.linuxjournal.com/users/shawn-powers" lang="" about="https://www.linuxjournal.com/users/shawn-powers" typeof="schema:Person" property="schema:name" datatype="" xml:lang=""&gt;Shawn Powers&lt;/a&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"&gt;&lt;p&gt;
I've written a little about PHP before, because I think it's a great
utility language for writing quick things you need to do. Plus, it
allows you to use a web browser as your interface, and everyone has
a web browser. That makes it very convenient for my family, because I
can make simple web interfaces for the various things I normally have to
do from the command line. (This is extremely useful when I'm gone to a
conference and the Plex server needs to be rebooted, or any of a dozen
other things need to be done that are hard to explain over the phone.)
&lt;/p&gt;

&lt;p&gt;
My "Family Dashboard" will look different from yours, but the concept is
pretty simple. PHP allows you to execute local functions on the server,
and so as long as you can create a bash script that does what you need it
to do, it can be launched from the "dashboard" you create for your
family. Here's a sample dashboard file I've created, so you can see
how simple it is to create a custom page that does what you need it to do
(see Figure 1 for a screenshot of the dashboard in action):

&lt;/p&gt;&lt;pre&gt;
&lt;code&gt;
&lt;html&gt;&lt;head&gt;&lt;title&gt;My Dashboard&lt;/title&gt;&lt;/head&gt;
&lt;body&gt;
&lt;h3&gt;You need to enter some commands and possibly options,
 ↪or just press a button:&lt;br /&gt;
&lt;button onclick="window.location='lj.php?command=weather&amp;
↪option=houston'"&gt;Weather&lt;/button&gt;
&lt;button onclick="window.location='lj.php?command=bing'"&gt;Bing
 ↪Photo&lt;/button&gt;
&lt;button onclick="window.location='lj.php?command=uname'"&gt;Kernel
 ↪Name&lt;/button&gt;
&lt;button onclick="window.location='lj.php?command=time'"&gt;Unix
 ↪Time&lt;/button&gt;
&lt;/h3&gt;

&lt;?php

$command = $_GET['command'];
$option = $_GET['option'];

switch ($command)
{
    case "weather":
        echo file_get_contents("https://wttr.in/$option");
        break;
    case "time":
        echo time() . "  &lt;-- that's how I read time! I'm a robot!";
        break;
    case "bing":
        $json = json_decode(file_get_contents("https://www.bing.com/
↪HPImageArchive.aspx?format=js&amp;idx=0&amp;n=1&amp;mkt=en-US"), TRUE);
        $url = "https://bing.com" . $json['images']['0']['url'];
        echo "Here is the image of the day:\n";
        echo "&lt;img src=$url /&gt;";
        break;
    case "uname":
        echo shell_exec("uname -a");
        break;
    default:
        echo "&lt;h1&gt;Press a button!&lt;/h1&gt;";

}

?&gt;
&lt;/body&gt;&lt;/html&gt;
&lt;/code&gt;
&lt;/pre&gt;

&lt;img src="https://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1000009/12115f1.png" alt="" title="" class="imagecache-large-550px-centered" /&gt;&lt;p&gt;
&lt;strong&gt;Figure 1. My dashboard is simple, but it's just a front end for the
code beneath.&lt;/strong&gt;
&lt;/p&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-link field--type-ds field--label-hidden field--item"&gt;  &lt;a href="https://www.linuxjournal.com/content/family-dashboard" hreflang="und"&gt;Go to Full Article&lt;/a&gt;
&lt;/div&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;

</description>
  <pubDate>Tue, 23 May 2017 14:52:10 +0000</pubDate>
    <dc:creator>Shawn Powers</dc:creator>
    <guid isPermaLink="false">1339395 at https://www.linuxjournal.com</guid>
    </item>
<item>
  <title>PHP for Non-Developers</title>
  <link>https://www.linuxjournal.com/content/php-non-developers</link>
  <description>  &lt;div data-history-node-id="1338760" class="layout layout--onecol"&gt;
    &lt;div class="layout__region layout__region--content"&gt;
      
            &lt;div class="field field--name-field-node-image field--type-image field--label-hidden field--item"&gt;  &lt;img src="https://www.linuxjournal.com/sites/default/files/nodeimage/story/11783f1.png" width="546" height="254" alt="" typeof="foaf:Image" class="img-responsive" /&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-author field--type-ds field--label-hidden field--item"&gt;by &lt;a title="View user profile." href="https://www.linuxjournal.com/users/shawn-powers" lang="" about="https://www.linuxjournal.com/users/shawn-powers" typeof="schema:Person" property="schema:name" datatype="" xml:lang=""&gt;Shawn Powers&lt;/a&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"&gt;&lt;p&gt;
After years of making it clear that I'm not a developer in just
about every article I've written here at &lt;em&gt;Linux Journal&lt;/em&gt;, I do have a
confession to make. I can write the "Hello World" equivalent in almost
every programming language out there. In assembly, it might have been
"1+1", but my lack of advanced skills should be evident. The thing is,
I've always wanted to learn how to program, but I hate the process so
much I never get past "Hello World".
&lt;/p&gt;
&lt;p&gt;
Then I met PHP.
&lt;/p&gt;

&lt;p&gt;
I know PHP is no longer cool. I know that compared to Python it's
extremely limited. But I also know that with PHP, I actually was able to 
create useful programs from the beginning. I suspect that's why I love
Bash scripting so much. With Bash, I always start with a problem to solve
and use scripting to solve it. I never "learned" to write Bash scripts,
I just did it. My goal in this article is to throw you right into writing
useful PHP code. If you really want to make "Hello World" appear in a
browser window, by all means do so. But I'm not going to teach you how!
&lt;/p&gt;

&lt;h3&gt;
Preliminaries&lt;/h3&gt;

&lt;p&gt;
&lt;em&gt;&lt;strong&gt;Server:&lt;/strong&gt;&lt;/em&gt;
&lt;/p&gt;

&lt;p&gt;
One great thing about PHP is that just about every Web server has it
installed and ready to go. If you get advanced and want to start making
system calls to the underlying Linux OS, you might have to tweak php.ini
a bit, but getting a PHP platform is usually as simple as installing
a Web server with a LAMP stack.
&lt;/p&gt;

&lt;p&gt;
One thing that makes programming easier for me is to make sure my user
account has write access to the place I'm writing code. My process usually
involves making a small change and clicking refresh on the browser to see
if it worked. If you have to &lt;code&gt;sudo cp localfile
serverfile&lt;/code&gt; every time you
make a change, it will be no fun. Worry about proper file permissions when
you release your code to the Internet, but not while you're developing.
&lt;/p&gt;

&lt;p&gt;
The only other server tweak I recommend is adding a .htaccess that
turns on error reporting. I don't always have errors display on the
page, but if you get the dreaded "php blank page", it's nice to 
turn on error reporting quickly so you get a nice message telling you where you
forgot a semicolon. I usually create a file called "err" and quickly
rename it to ".htaccess" when I want to see errors displayed. You 
probably will have to modify your Apache server, telling it to
"AllowOverride"
for the folder you're using, but it's worth the effort. Here's what my
.htaccess file looks like:

&lt;/p&gt;&lt;pre&gt;&lt;code&gt;
php_flag  display_errors        on
php_value error_reporting       2039
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;em&gt;&lt;strong&gt;
Editor:&lt;/strong&gt;&lt;/em&gt;
&lt;/p&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-link field--type-ds field--label-hidden field--item"&gt;  &lt;a href="https://www.linuxjournal.com/content/php-non-developers" hreflang="und"&gt;Go to Full Article&lt;/a&gt;
&lt;/div&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;

</description>
  <pubDate>Tue, 30 Jun 2015 14:00:00 +0000</pubDate>
    <dc:creator>Shawn Powers</dc:creator>
    <guid isPermaLink="false">1338760 at https://www.linuxjournal.com</guid>
    </item>

  </channel>
</rss>
