Find profiles example of using 51Degrees device detection. The example
shows how to:
- Fetch a pointer to the 51Degrees device detection provider instance.
This is instantiated on server startup and uses settings from php.ini.
$provider = FiftyOneDegreesPatternV3::provider_get();
- Retrieve all the profiles in the data set with the specified property
value pair
$profiles = $provider->findProfiles("IsMobile", "True");
- Search within a list of profiles for another property value pair.
$profiles = $provider->findProfilesInProfiles("ScreenPixelsWidth", "1080", $profiles);
This example assumes you have the 51Degrees PHP API installed correctly,
and have FiftyOneDegreesPatternV3.php in this directory.
*/
// Snippet Start
require("../pattern/FiftyOneDegreesPatternV3.php");
$provider = FiftyOneDegreesPatternV3::provider_get();
echo "Starting Find Profiles Example.
\n";
// Retrive all the mobile profiles.
$profiles = $provider->findProfiles("IsMobile", "True");
echo "There are ".$profiles->getCount()." mobile profiles in the ".
$provider->getDataSetName()." data set.
\n";
// Find how many have a screen width of 1080 pixels.
$profiles = $provider->findProfilesInProfiles("ScreenPixelsWidth", "1080", $profiles);
echo $profiles->getCount()." of them have a screen width of 1080 pixels.
\n";
// Retrive all the non-mobile profiles.
$profiles = $provider->findProfiles("IsMobile", "False");
echo "There are ".$profiles->getCount()." non-mobile profiles in the ".
$provider->getDataSetName()." data set.
\n";
// Find how many have a screen width of 1080 pixels.
$profiles = $provider->findProfilesInProfiles("ScreenPixelsWidth", "1080", $profiles);
echo $profiles->getCount()." of them have a screen width of 1080 pixels.
\n";
// Snippet End
?>