Jump to content
Sign in to follow this  
phpnoob

Oop/class In Php

Recommended Posts

salam semua abg kakak putra..

adik ada sikit kekeliruan la.. tak paham macam mana nak settle bende ni. harap ada abg kakak yang sudi tolong..

adik tunjuk codeing dia dulu..

<?php
	class HTMLtable	{
  var $TDs;
  var $THs;
  var $TRs;
  var $TDAttrs;
  var $TDClasses;
  var $rowNum;
  var $colNum;
  
  function HTMLtable($rows,$cols,$attrs)	{
  	$this->rows = $rows;
  	$this->cols = $cols;
  	$this->attrs = $attrs;
  }

  function addText($row,$col,$text,$class)	{
  	$idx = ($row * $this->cols) + $col;
  	$this->TDs[$idx] .= $text;                  /* line 19 */
  	$this->TDClasses[$idx] .= $class;       /* line 20 */
  }
  
  function printTable()	{
  	$attrs = $this->attrs;
  	print("<TABLE $attrs>");
  	for($rows=0;$rows < $this->rows;$rows++)	{
    print("<TR>");
    for($cols=0;$cols < $this->cols;$cols++)	{
    	$idx = ($rows * $this->cols) + $cols;
    	$tag = "<TD";
    	if($this->TDClasses[$idx])	{
      $tag .= " class = "  .$this->TDClasses[$idx] . ">";
    	} else {
      $tag .= ">";
    	}
    	$tag .= $this->TDs[$idx];
    	$tag .= "</TD>";
    	print($tag);
    }
    print("</TR>");
  	}
  	print("</TABLE>");
  	
  }
	}
?>

test kat PHP Version 4.4.0 dia jadi macam ni

user posted image

test kat PHP Version 4.3.4 dia jadi macam ni

user posted image

blh adik tahu macam mana nak settle benda ni kalau nak pakai php v 4.4.0 dan keatas??

Edited by phpnoob

Share this post


Link to post
Share on other sites

mungkin php 4.4 dah tak istihar gaya php4.3 tu,,

mungkin tak guna var dah ..

pengistiharan public

Share this post


Link to post
Share on other sites

erm pelik nie.. tapi memang PHP 4.4 nie dia dah selesaikan problem yang ada kat PHP4.3 nie....

Ko kena buat satu Koding yang memungkinkan ia tidak berlaku.. dalam perkatan lain macam nie..

Saya Nak Pi Kedai,

Kalau Hujan Saya Nak Pi MIniMarket

Kalau Tak Ujan Baru saya PI mini Market

hehehe

Dengan kata lain

$this->TDs[$idx] .= $text;                  /* line 19 */
  $this->TDClasses[$idx] .= $class;       /* line 20 */

$idx

Tidak Di Istiharkan.... pi ar defined natang nie....

Edited by naszari

Share this post


Link to post
Share on other sites

Berdasarkan ilmu PHP aku yg serba cetek ni, aku rasa tu sebab kita tak isytiharkan variable $TDClasses dan $TDs sbg array.. cuba kalau mcm ni:

var $TDs = array();
var $TDClasses = array();

Tak pasti pasal notice tu, mungkin benda tu termasuk dlm changelist dari 4.3.4 to 4.4 ..

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...