Codoforum related discussions
Changes in php 7

Hi,
I have this code in php 5 and whant to adapt for php 7.2
I have tried using foreach instead of While but it returns error sayng "Array to string convertion" in line "$er.= "<b>".$key."</b>: ".$value." after foreach.
Does anybody know how to solve this?
Thank you.

public function getResumen(){
$er="";
$ar = $this->getTrace();
$er.= "<b>Mensaje</b>: ".$this->message."<br/>";
$er.= "<b>Código</b>: ".$this->code."<br/><br/>";
foreach ($ar as $a=>$p){

        //foreach($p as $key => $value){
        while(list($key, $value) = each($p)){ 
            //echo();                
            $er.= "<b>".$key."</b>: ".$value."<br/>";

            ;
        }
    }
    $in="<div style=\"border:1px solid #000000;padding:10px;background:#f6ca6d;\">";
    $in.="<b>Escepsión Resumen</b>:<br/><br/>";
    $in.=$er;
    $in.="</div><br/>";
    return $in;
Hi, I have this code in php 5 and whant to adapt for php 7.2 I have tried using foreach instead of While but it returns error sayng &quot;Array to string convertion&quot; in line &quot;$er.= &quot;&lt;b&gt;&quot;.$key.&quot;&lt;/b&gt;: &quot;.$value.&quot; after foreach. Does anybody know how to solve this? Thank you. public function getResumen(){ $er=&quot;&quot;; $ar = $this-&gt;getTrace(); $er.= &quot;&lt;b&gt;Mensaje&lt;/b&gt;: &quot;.$this-&gt;message.&quot;&lt;br/&gt;&quot;; $er.= &quot;&lt;b&gt;C&oacute;digo&lt;/b&gt;: &quot;.$this-&gt;code.&quot;&lt;br/&gt;&lt;br/&gt;&quot;; foreach ($ar as $a=&gt;$p){ //foreach($p as $key =&gt; $value){ while(list($key, $value) = each($p)){ //echo(); $er.= &quot;&lt;b&gt;&quot;.$key.&quot;&lt;/b&gt;: &quot;.$value.&quot;&lt;br/&gt;&quot;; ; } } $in=&quot;&lt;div style=\&quot;border:1px solid #000000;padding:10px;background:#f6ca6d;\&quot;&gt;&quot;; $in.=&quot;&lt;b&gt;Escepsi&oacute;n Resumen&lt;/b&gt;:&lt;br/&gt;&lt;br/&gt;&quot;; $in.=$er; $in.=&quot;&lt;/div&gt;&lt;br/&gt;&quot;; return $in;

For the most part, PHP 5.x code can run unchanged on PHP 7. There are a few changes, however, that are classified as backwards incompatible. What this means is that if your PHP 5 code is written in a certain way, or uses functions that have been removed, your code will break, and you'll have a nasty error on your hands.

Read more about to solv Your problem here:

https://subscription.packtpub.com/book/application_development/9781785883446/1/ch01lvl1sec17/creating-a-php-5-to-php-7-code-converter

For the most part, PHP 5.x code can run unchanged on PHP 7. There are a few changes, however, that are classified as backwards incompatible. What this means is that if your PHP 5 code is written in a certain way, or uses functions that have been removed, your code will break, and you&#039;ll have a nasty error on your hands. Read more about to solv Your problem here: https://subscription.packtpub.com/book/application_development/9781785883446/1/ch01lvl1sec17/creating-a-php-5-to-php-7-code-converter

45 years old and still not smarter lol

Check my GitHub Repos: https://github.com/WebCrew

My CrazyMates Account: https://crazymates.de/Crazymate

Cute but Evil Community: https://cute-but-evil.de

14
1
2
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft