2016-06-25 6 views
0

Wie wird das Bild if(isset($post->foto) im Code unten wiedergegeben? Ich versuche mit dem untenstehenden Code, aber ich kann keine Lösung finden. Seine Rückkehr wird folgende FehlerWie kann ich das Bild in HTML und PHP wiedergeben?

Parse error: syntax error, unexpected 'userdata' (T_STRING), expecting ',' or ';'.

foreach($postimet as $post){ 
    $firstname = $user->getUserById($post->userid)['first']; 
    $lastname = $user->getUserById($post->userid)['last']; 
    foreach($fotos as $foto){ 
     echo 
     "<div class='po_001'> 
      <div class='po_004'> 
       <img src='timeline/".$foto."' class='po_003'> 
       <div class='po_005'> 
        <a href='profile.php' class='po_002'>$firstname $lastname</a> 
       </div> 
       <div class='po_006'> 
        <span class='p_007'>$post->posttime</span> 
       </div> 
      </div> 
      <div class='po_008'> 
       <p class='po_009'>$post->message</p> 
      </div> 
      <div class='po_010'> 
      if(isset($post->foto)) 
       { 
       <img class='myimage'src='"userdata/".$post->foto->imagename."'> 
       } 
      </div> 
     </div>"; 
    }      
} 

Antwort

0

Sie müssen es wie unten tun: -

<?php 
foreach($postimet as $post){ 
    $firstname = $user->getUserById($post->userid)['first']; 
    $lastname = $user->getUserById($post->userid)['last']; 
    foreach($fotos as $foto){?> 
     <div class='po_001'> 
      <div class='po_004'> 
       <img src="timeline/<?php echo $foto;?>" class='po_003'> 
       <div class='po_005'> 
        <a href='profile.php' class='po_002'>$firstname $lastname</a> 
       </div> 
       <div class='po_006'> 
        <span class='p_007'>$post->posttime</span> 
       </div> 
      </div> 
      <div class='po_008'> 
       <p class='po_009'>$post->message</p> 
      </div> 
      <div class='po_010'> 
      <?php if(isset($post->foto)){?> 
       <img class='myimage'src="userdata/<?php echo $post->foto->imagename;?>"> 
       <?php } ?> 
      </div> 
     </div> 
    <?php }      
} 
?> 
3

verwenden in echo-Anweisung:

<img class='myimage'src='userdata/'".$post->foto->imagename."'> 

Statt:

<img class='myimage'src='"userdata/".$post->foto->imagename."'> 
+0

Bereits habe ich versucht, es hilft nicht. –

+0

$ user = neuer Benutzer(); $ user-> getInfo(); $ img_prof = new ImageProfile(); $ fotos = $ img_prof-> getProfile(); if (isset ($ user2)) { $ postimet = $ benutzer-> allMyPosts ($ _ GET ['id']); } sonst { $ postimet = $ user-> allMyPosts ($ _ SESSION ['id']); } foreach ($ postimet als $ post) { $ firstname = $ benutzer-> getUserById ($ post-> userid) ['first']; $ lastname = $ user-> getUserById ($ post-> Benutzer-ID) ['last']; foreach ($ fotos als $ foto) { –

+0

Genau, jetzt funktioniert perfekt, danke mann :) –

0

Sie versuchen, so etwas zu finden?

<?php 

    $html->tag('doctype')->alone('html')->tag(); 
    $html->tag('html')->lang('en'); 

     $html->tag('head'); 
      $html->tag('meta')->charset('utf-8')->tag(); 
      $html->tag('meta')->httpequiv('X-UA-Compatible')->content('IE=edge')->tag(); 
      $html->tag('meta')->name('viewport')->content('width=device-width, initial-scale=1')->tag(); 
      $html->tag('meta')->name('description')->content('Brosta Tools')->tag(); 
      $html->tag('meta')->name('author')->content('Brosta')->tag(); 
      $html->tag('title')->text('Brosta Tools')->tag(); 
      $html->tag('link')->href('assets/plugins/bootstrap/css/bootstrap.min.css')->rel('stylesheet')->tag(); 
      $html->tag('link')->href('assets/plugins/bootstrap/css/simple-sidebar.css')->rel('stylesheet')->tag(); 
      $html->tag('link')->href('assets/plugins/prism/css/prism.css')->rel('stylesheet')->tag(); 
      $html->tag('link')->href('assets/plugins/normalize/css/normalize.css')->rel('stylesheet')->tag(); 
      $html->tag('link')->href('assets/plugins/brosta/css/brosta.css')->rel('stylesheet')->tag(); 

      $html->tag('script')->src('assets/plugins/bootstrap/js/jquery.js')->type('text/javascript')->tag(); 
      $html->tag('script')->src('assets/plugins/bootstrap/js/bootstrap.min.js')->type('text/javascript')->tag(); 
      $html->tag('script')->src('assets/plugins/prism/js/prism.js')->type('text/javascript')->tag(); 
      $html->tag('script')->type('text/javascript')->text('$("#menu-toggle").click(function(e) {e.preventDefault(); $("#wrapper").toggleClass("toggled"); });')->tag(); 
      $html->tag('script')->type('text/javascript')->text(' 
       window.onload = function() { 
        var x = document.getElementsByClassName("token"); 
        var i; 
        for (i = 0; i < x.length; i++) { 
         var variable = x[i].getAttribute("class").replace("token ", ""); 
         var text = x[i].innerText.trim().replace("$", ""); 
         if(!/[^a-zA-Z0-9]/.test(text) || text.indexOf("_") >= 0) { 
          x[i].className +=" " + variable + "-" + text; 
         } 
        } 
       } 
      ')->tag(); 
     $html->tag(); 

     $html->tag('body')->class('brosta'); 

      $html->include('snippets.brosta.navbar'); 

      $html->tag('div')->class('container-fluid brosta'); 
       $html->tag('div')->id('wrapper'); 
        $html->tag('div')->id('sidebar-wrapper'); 
         $html->tag('ul')->class('sidebar-nav'); 

          $data = [ 
           ['link' => '/Instalation', 'text' => 'Instalation'], 
           ['link' => '/Html', 'text' => 'Html'] 
          ]; 

          foreach($data as $link) 
          { 
           $html->tag('li'); 
            $html->tag('a')->href($link['link'])->text($link['text'])->tag(); 
           $html->tag(); 
          } 

         $html->tag(); 
        $html->tag(); 
        $html->tag('div')->id('page-content-wrapper'); 
         $html->tag('div')->class('row'); 
          $html->tag('div')->class('col-lg-12'); 
           $html->tag('div')->class('panel panel-default'); 
            $html->tag('div')->class('panel-heading clearfix')->text('Without Time')->tag(); 
            $html->tag('div')->class('panel-body'); 
             $html->tag('p')->text('Make a file in your root public server. Ex: <code class="language-php">C:\xampp\htdocs\index.php</code>')->tag(); 
             $html->tag('pre')->class('language-php'); 
              $html->tag('code')->class('language-php')->text($html->specialChars('views/content.php'))->tag(); 
             $html->tag(); 
            $html->tag(); 
           $html->tag(); 
          $html->tag(); 
         $html->tag(); 
        $html->tag(); 
       $html->tag(); 
      $html->tag(); 
     $html->tag(); 
    $html->tag(); 

echo $html->get(); 
Verwandte Themen