PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, January 29, 2022

[FIXED] CakePHP Unsupported Operand

 January 29, 2022     cakephp, operand, php     No comments   

Issue

I am getting the below error in CakePHP, the function works fine in PHP just not Cake, does anyone know why this is not supported or a workaround?

Error: Unsupported operand types
File: /var/www/spitdev/console2/app/Lib/IpLib.php
Line: 40

Notice: If you want to customize this error message, create app/View/Errors/fatal_error.ctp

Function:

public function lastHost($ip_add, $subnet_mask){
    $ip = ip2long($ip_add);
    $nm = ip2long($subnet_mask);
    $nw = ($ip & $nm);
    $bc = $nw | (~$nm); <------------LINE 40
    $lh = long2ip($bc - 1);
    return $lh;
}

Solution

This is not problem of operand but of value passing.Make sure that $ip_add and $subnet_mask are getting VALID values and not empty. Because

$test=$this->lastHost('69.89.31.226','255.0.0.0');
var_dump($test);

returning valid result while

$test_again=$this->lastHost('','');
var_dump($test_again);

returning same error as you specified



Answered By - Shashikala
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing