title: Can't convert string to int in Laravel in PHP
body: <p>I am unable to convert a string to an int in PHP.</p>
  
  <p>To give a little background, I am writing tests in Laravel</p>
  
  <p>//    This is method from my test class</p>
  
  <pre><code>public function testIsNumberValidUnit(){
  
      $this-&gt;visit('/unitTest/isNumberValid/9647')
           -&gt;see("0");
  }
  </code></pre>
  
  <p>//this is my route that is called </p>
  
  <pre><code>Route::group(['prefix' =&gt; 'unitTest'], function(){
  
          //tests method in post controller to see if phone number is valid
      Route::get('/isNumberValid/{fromNumber}', [
  
              'uses' =&gt; 'SomeController@isNumberValid',
              'as' =&gt; 'unitTest.isNumberValid'
  
      ]);
  
  }
  </code></pre>
  
  <p>//This is my Controller method. $fromNumber comes as a string, and I am unable to convert it to an int, no matter what I do.</p>
  
  <pre><code>public function isNumberValid($fromNumber){
  
       //check if fromNumber is an integer else convert it to be an integer
          if(!is_int($fromNumber)){
  
      // $fromNumber = (int)$fromNumber;
         settype($fromNumber, 'integer');
         Log::info( $fromNumber . " is of type ". gettype($fromNumber));
  
      }
       //other code
  }
  </code></pre>
  
  <p>Log record shows (and this does work):</p>
  
  <pre><code>9647 is of type integer
  </code></pre>
  
  <p>So far, I have tried the following to convert fromNumber to an int:</p>
  
  <pre><code>$number1 = $fromNumber+ 0;
  $number1 = intval ($fromNumber);
  $number1 = (int)$fromNumber
  settype($fromNumber, 'integer');
  </code></pre>
  
  <p>but none have worked.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>Edit: So even though I was able to convert from string to int. I kept getting the same error about something not being able to convert to int. But on closer inspection i noticed the issue is with my twilio lookup which says "exception 'ErrorException' with message 'Object of class Twilio\Exceptions\EnvironmentException could not be converted to int'. </p>
  
  <p>This question can be marked as closed.If needed I will create anothr question for my twilio issue.</p>
  
  <p>Thanks guys!</p>