Home > Enterprise >  open url from php snippet in chrome
open url from php snippet in chrome

Time:01-09

In one of scripts I use daily I have something like this:

<?php

$args = explode("\n", $argv[1]);

// loop through args
foreach ($args as $arg) {
    
    // create the url
    $url = 'https://trends.google.pl/trends/explore?date=now 7-d&geo=PL&q=,' . urlencode(trim($arg));

    // open the url in the default browser
    shell_exec('open ' . escapeshellarg($url));
}

?>

How to change this part

// open the url in the default browser
    shell_exec('open ' . escapeshellarg($url));

to open the URL in chrome browser? Because for now it opens it in default browser and I don't want to change the default browser to chrome in my os (macos)

CodePudding user response:

You can use -a flags and the application name

shell_exec('open -a "Google Chrome" '.escapeshellarg($url));
  •  Tags:  
  • Related