Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing Argument via Command Line php

So I have this script that I'm trying to pass the argument via command line. But, can't get it to work. Here's the code for the script:

#!/usr/bin/php 

<?php
$argv[1] = $scraper;
require_once('Scraper.php');
$scraper = new JonH_Scraper();

if (empty($argv[1])) {
    echo 'whats the URL?';
    }

$scraper->scrape($url);
var_dump($scraper);
like image 697
Jon Avatar asked Sep 22 '26 23:09

Jon


1 Answers

the mistake is here

$argv[1] = $scraper;

it should be

$scraper = $argv[1];

regards


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!