File: example.php

Recommend this page to a friend!
  Classes of Dave Smith  >  PHP Language Detection Library  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example Usage
Class: PHP Language Detection Library
Detect the language of a text using APILayer
Author: By
Last change:
Date: 5 years ago
Size: 662 bytes
 

 

Contents

Class file image Download
<?php
/*
example usage
languageLayer ver 1.0

You must get an API key from https://languagelayer.com/product
and enter it in the langlayer.class.php file
*/

//turning off low level notices
error_reporting(E_ALL ^ E_NOTICE);

//text to test
$text = 'Ich bin mir sicher, dass dies die Sprache Deutsch';

//instantiate the class
include('langlayer.class.php');
$lang = new languageLayer();

//get the response from the api
$lang->getResponse($text);

//check for reported error
if( $lang->errorCode ){
   
    die(
'error ('.$lang->errorCode.'): '.$lang->errorText);
   
}

//show the response object
var_dump($lang->response);
?>


For more information send a message to info at phpclasses dot org.