PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of vince  >  PHP Premier League API  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Premier League API
Retrieve information about the UK Premier League
Author: By
Last change: Example update and added sort to getTeams
Date: 6 years ago
Size: 2,605 bytes


Class file image Download
/** utilise composor to autoload dependancies **/
require 'vendor/autoload.php';


try {
$epl = new PremierLeague();
// returns raw data
    //$data = $epl->getData();
    // returns current season: "2015-2016"
    //$data = $epl->getSeason();
    // returns all team details
$data = $epl->getTeams();
// returns single team details
    //$data = $epl->getTeam('Liverpool');
    // returns all matches raw data
    //$data = $epl->getMatches();
    // returns all matches for team, inc club badges
    //$data = $epl->getMatches('Liverpool');
    // returns teams next match details
    //$data = $epl->getNextMatch('Liverpool');
    // returns all current standing details
    //$data = $epl->getStandings();
    // returns teams current standing details
    //$data = $epl->getStanding('Liverpool');
} catch (Exception $e) {
'Fatal error: ' . $e->getMessage());
<!doctype html>
<html lang="en">
        <title>PHP Premier League</title>
        <link href="" rel="stylesheet" integrity="sha256-7s5uDGW3AHqw6xtJmNNtr+OBRJUlgkNJEo78P4b0yRw= sha512-nNo+yCHEyn0smMxSswnf/OnX6/KwJuZTlNZBjauKhTK0c+zT+q5JOCx0UFhXQ6rJR9jg6Es8gPuD2uZcYDLqSw==" crossorigin="anonymous">
        <nav class="navbar">
          <div class="container">
            <div class="navbar-header">
              <a class="navbar-brand" href="#">PHP Premier League Example</a>
        <div class="container">
            <div class="row">
                <div class="col-md-7">
                    <table class="table table-hover col-md-4">
                            <th>Next game</th>
                            <?php foreach($data as $team) { ?>
                                <td><?php echo $team['standing'] ?></td>
                                <td><img src='<?php echo $team['badge'] ?>' height='20px'/></td>
                                <td><?php echo $team['name'] ?></td>
                                <td><?php echo $team['played'] ?></td>
                                <td><?php echo $team['points'] ?></td>
                                    <img src='<?php echo $epl->getNextMatch($team['name'])['homeTeamBadge']; ?>' height='20px'/>
                                    <img src='<?php echo $epl->getNextMatch($team['name'])['awayTeamBadge']; ?>' height='20px'/>
                            <?php } ?>