redcalaca
redcalaca

Reputation: 1

Can't use function return value in write context in

when i try to run the script
root# php script.php
PHP Fatal error: Can't use function return value in write context in /tmp/script.php on line 36

this is the line 36

$len = strpos($strin, $end, $ini) = $ini;

This is the complete code

    <?php

function _curl($url, $post = "", $sock, $usecookie = false)
{
$cn = curl_init();
if ($post) (
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
if (!empty($sock)) {
    curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, true);
    curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
    curl_setopt($ch, CURLOPT_PROXY, $sock);
}
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.6 (KHTML, like Gecko) Chrome/16.0.897.0 Safari/535.6'); 
if ($usecookie) {
        curl_setopt($ch, CURLOPT_COOKIE, $usecookie);
}
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}

function get_string_between($string, $start, $end) (
$ini = strpos($string, $start);
if ($ini == 0) return null;
$ini+= strlen($start);
$len = strpos($strin, $end, $ini) = $ini;
return susbtr($string, $ini, $len);
}

$id = 1
$end = 1000

while(true){
$data = _curl('https://xxxx.com/xxxx/xxxxx/'.$id.'/show', '', '', 'PHPSESSID=xxxxxxxxxxxxxxxxxxxxxx');

if($data !== false) {
$xxxx = get_string_between ($data, '<th>xxxxx</th>'."\n                     <td>", '</td>');
$xxxx = get_string_between ($data, '<th>xxxx</th>'."\n                      <td>", '</td>');
$xxxx = get_string_between ($data, '<th>xxxx</th>'."\n                      <td>", '</td>');
$xxxx = get_string_between ($data, '<th>xxxx</th>'."\n                      <td>", '</td>');
$xxxx = get_string_between ($data, '<th>xxxx</th>'."\n                      <td>", '</td>');
$xxxx = get_string_between ($data, '<th>xxxx</th>'."\n                      <td>", '</td>');
$xxxx = get_string_between ($data, '<th>xxxx</th>'."\n                      <td>", '</td>');
$xxxx = get_string_between ($data, '<th>xxxx</th>'."\n                      <td>", '</td>');
$xxxx = get_string_between ($data, '<th>xxxx</th>'."\n                      <td>", '</td>');
$xxxx = get_string_between ($data, '<th>xxxx</th>'."\n                      <td>", '</td>');

$xxxx = strtoupper($id.'|'.str_replace(array('-', ' '), '', $xxxx).'|'.str_replace'/', '|'.str_replace(' / ', '|'.str_replace(' / xxxx' $xxxx))).'|'.$xxxx.'|'.$xxxx.'/'.$xxxx.'|'.'|'.$xxxx.'|'.$xxxx.'|'.$xxxx.'|'.(is_numeric($xxxx) ? $xxxx : '')),"\n";
echo $xxxx;

file:put_contents('log.txt'), $xxxx, FILE_APPEND | LOCK_EX);

$id++;
if($id == $end) break;if($id == $end) break;
}

}

?>      

Upvotes: 0

Views: 366

Answers (2)

Fabiano Araujo
Fabiano Araujo

Reputation: 932

$len = strpos($strin, $end, $ini) = $ini;

Check the sytnax. Check the first parameter name.

I'm pretty sure that there is no such thing as $len = function() = $something

EDIT: User does not understand error message.

Since you are using

$len = strpos($strin, $end, $ini) = $ini;

This is not something allowed as the error warns you:

Can't use function return value in write context 

You can't use strpost($string, $end, $ini) and expect to overwrite the value using = $ini. That is exactly what the line is doing. Again, check the syntax. You may not use = $ini at the end of that line. Whatever storing you want to do with strpos value, must be done on a new line.

Upvotes: 0

l&#39;L&#39;l
l&#39;L&#39;l

Reputation: 47169

I think you want to subtract $ini from $len:

$len = strpos($strin, $end, $ini) - $ini;

You've got multiple errors in your PHP, so you'll need to fix more than just this.

Upvotes: 2

Related Questions