• Login
  • Register
  • Zoek
This Thread
  • Everywhere
  • This Thread
  • This Forum
  • Articles
  • Pages
  • Forum
  • Filebase Entry
  • More Options

ICTscripters

Dé plek voor IT

Dé plek voor IT

Login

Geavanceerde opties
  1. Home
  2. Forum
    1. Alle berichten
    2. Recente activiteiten
  3. ICT Nieuws
  4. Blog
  5. Marktplaats
    1. Werk
    2. Advertenties
    3. Domeinnamen
    4. Websites
    5. Design & lay-outs
    6. Scripts
    7. Overige
  6. Design
  7. Leden
    1. Actieve bezoekers
    2. Team
    3. Leden zoeken
  8. Downloads
  9. Goedkope domeinnamen
  1. Home
  2. Forum
    1. Alle berichten
    2. Recente activiteiten
  3. ICT Nieuws
  4. Blog
  5. Marktplaats
    1. Werk
    2. Advertenties
    3. Domeinnamen
    4. Websites
    5. Design & lay-outs
    6. Scripts
    7. Overige
  6. Design
  7. Leden
    1. Actieve bezoekers
    2. Team
    3. Leden zoeken
  8. Downloads
  9. Goedkope domeinnamen
  1. Home
  2. Forum
    1. Alle berichten
    2. Recente activiteiten
  3. ICT Nieuws
  4. Blog
  5. Marktplaats
    1. Werk
    2. Advertenties
    3. Domeinnamen
    4. Websites
    5. Design & lay-outs
    6. Scripts
    7. Overige
  6. Design
  7. Leden
    1. Actieve bezoekers
    2. Team
    3. Leden zoeken
  8. Downloads
  9. Goedkope domeinnamen
  1. Dé plek voor IT - ICTscripters
  2. Forum
  3. Scripting & programmeren
  4. Advanced Programming

Forum

  • Het oorspronkelijke Criminals Script

    Jeroen.G 18 juni 2026 om 15:06
  • StraatBaas is back, maar hoe?!

    Syntax 17 juni 2026 om 10:28
  • RPG game gebouwd met AI

    Frenzo.Webservice 11 juni 2026 om 19:44
  • Het Grote Vibe Code Topic

    Syntax 1 juni 2026 om 20:05
  • PWYL source gezocht

    Syntax 29 mei 2026 om 14:03
  • Ictscripters Chat

    AarClay 21 april 2026 om 11:34
  • Help testers nodig voor android app Urgent

    Servertjee 20 februari 2026 om 12:07
  • Partner Gezocht om meerdere NFT Collecties op Open Sea te Plaatsen

    Servertjee 20 februari 2026 om 12:06

Marktplaats

  • 4-letter domein: Togi.nl

    evesi 17 juni 2026 om 17:08
  • 359 Nieuwe Domeinnamen Mei 2026

    shiga 1 juni 2026 om 12:45
  • Sicarras.com - Moderne Mafia Text-Based RPG

    Jeffrey.Hoekman 27 mei 2026 om 17:40

Tafel class

  • Patrick
  • 4 april 2010 om 11:08
  • Patrick
    Back in the game
    Ontvangen Reacties
    52
    Berichten
    1.417
    • 4 april 2010 om 11:08
    • #1
    PHP
    <?php
    
    
    /**
     * @author Patrick rennings
     * @copyright 2010
     */
    
    
    class Tafel {
        
        
        protected $iCount;
        protected static $iMaxOutPut;
        protected $MathOutPut;
        
        public function __construct ( $Count, $MaxOutPut = NULL)
        {
            
            if ( !is_int ( $Count ) OR empty ( $Count ) )
            {
                    
                $this->iCount = 1;
                    
            }
            else
            {
                
                $this->iCount = $Count;
                
            }
            if ( !is_int ( $MaxOutPut ) OR empty ( $MaxOutPut ) AND empty ( self::$iMaxOutPut ) )
            {
    
    
                self::$iMaxOutPut = 10;
                    
            }
            else
            {
                
                self::$iMaxOutPut = $MaxOutPut;
                
            }
      
            $this->Math( $this->iCount, self::$iMaxOutPut );
                    
        }
        
        private function Math ( $CalcNum, $MaxOutPut )
        {
            
            $sArrayMath = array ( );
            
            for ( $iMath = 1; $iMath <= $MaxOutPut; $iMath++ )
            {
                
                $sArrayMath[] = $iMath . ' x ' . $CalcNum . ' = ' . $iMath * $CalcNum;
                
            }
            
            $this->MathOutPut = $sArrayMath;
            
        }
        
        public function ResultMath ( )
        {
            
            return $this->MathOutPut;
            
        }
        
    }
    
    
    $Math = new Tafel (4,20);
    
    
    foreach ( $Math->ResultMath() AS $Calculation )
    {
        
        echo $Calculation . ' <br /> ';
        
    }
    
    
    $Math2 = new Tafel (5);
    
    
    foreach ( $Math2->ResultMath() AS $Calculation )
    {
        
        echo $Calculation . ' <br /> ';
        
    }
    
    
    ?>
    Toon Meer

    Alles werkt, behalve de static variable, als ik de waarde = NULL meegeef aan $MaxOutPut wordt hij automatisch 10, maar als ik hem niet meegeef gaat hij mekkere dat er niks in staat,

    Hoe kan ik er een check inbouwen dat wanneer de static variable is gevuld dat hij die gewoon pakt wanneer er geen nieuwe gedefinieerd is?

    UPDATE:

    zo werkt hij naar mijn zin
    Comments?

    PHP
    <?php
    
    
    /**
     * @author Patrick rennings
     * @copyright 2010
     */
    
    
    class Tafel {
        
        
        protected $iCount;
        protected static $iMaxOutPut;
        protected $MathOutPut;
        
        public function __construct ( $Count, $MaxOutPut = NULL)
        {
            
            if ( !is_int ( $Count ) OR empty ( $Count ) )
            {
                    
                $this->iCount = 1;
                    
            }
            else
            {
                
                $this->iCount = $Count;
                
            }
            
            if ( ( !is_int ( $MaxOutPut ) OR empty ( $MaxOutPut ) ) AND empty ( self::$iMaxOutPut ) )
            {
    
    
                self::$iMaxOutPut = 10;
                    
            }
                
            elseif ( empty ( self::$iMaxOutPut ) OR ! empty ( $MaxOutPut ) )
            {
                    
                self::$iMaxOutPut = $MaxOutPut;
                
            }
      
            $this->Math( $this->iCount, self::$iMaxOutPut );
                    
        }
        
        private function Math ( $CalcNum, $MaxOutPut )
        {
            
            $sArrayMath = array ( );
            
            for ( $iMath = 1; $iMath <= $MaxOutPut; $iMath++ )
            {
                
                $sArrayMath[] = $iMath . ' x ' . $CalcNum . ' = ' . $iMath * $CalcNum;
                
            }
            
            $this->MathOutPut = $sArrayMath;
            
        }
        
        public function ResultMath ( )
        {
            
            return $this->MathOutPut;
            
        }
        
    }
    
    
    $Math = new Tafel (4,20);
    
    
    foreach ( $Math->ResultMath() AS $Calculation )
    {
        
        echo $Calculation . ' <br /> ';
        
    }
    
    
    $Math2 = new Tafel (5);
    
    
    foreach ( $Math2->ResultMath() AS $Calculation )
    {
        
        echo $Calculation . ' <br /> ';
        
    }
    
    
    ?>
    Toon Meer

  • Guest, wil je besparen op je domeinnamen? (ad)
  • NielsB
    Junior (Web)Developer
    Berichten
    948
    • 27 april 2010 om 10:50
    • #2

    Ik heb je script is bekeken en ik heb zelf ook er een gemaakt.
    Hij is een stukje korter geworden.
    Ben benieuwd of hier mensen zijn die het willen beoordelen?

    class.table.php

    PHP
    <?PHP
    // Class Table maken.
    class Table
    {
    	// Variabel decaleren.
        private $MathOutPut;
    	
    	// Gegevens door sturen.
    	public function __construct($iTable, $iMax)
    	{
    		// Checken of de inkomende gegevens bestaan.
    		if ( !is_int ( $iTable ) or empty ( $iTable ) ) 
    		{ 
    			$iCount = 7;
    		} 
    		else 
    		{
    			$iCount = $iTable;
    		}
         	
    		if ( !is_int ( $iMax ) or empty ( $iMax ) ) 
    		{
    			$MaxOutPut = 10;
    		}
    		else
    		{
    			$MaxOutPut = $iMax;
    		}
    		
    		// Math functie oproepen.
    		$this->Math( $iCount, $MaxOutPut );
    	}
    	
    	// Berekenen van de getallen.
    	private function Math( $CalcNum, $MaxOutPut )
    	{
    		// Array maken.
    		$sArrayMath = array();
    		
    		// Gegevens in array plaatsen.
    		for($i = 0; $i <= $MaxOutPut; $i++)
    		{
    			$sArrayMath[] = $i .' x '. $CalcNum .' = '. $i * $CalcNum;
    		}
    		
    		// Hele array in de output plaatsen.
    		$this->MathOutPut = $sArrayMath;
    	}
    	
    	// Weergeven van de tafel.
    	public function showTable()
    	{
    		// Output terug sturen zodat hij kan worden weergeven.
    		return $this->MathOutPut;	
    	}
    }
    Toon Meer

    Weergeven:
    tafel.php

    PHP
    <?PHP
    include "class.table.php";
    
    
    if($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['verzenden']))
    {
    	$tafel = new Table($_POST['tafel'], $_POST['maximaal']);
    
    
    	echo '<ul>';
    		foreach ( $tafel->showTable() AS $Calculation ) 
    		{ 
    			echo '<li>'. $Calculation . '</li>'; 
    		}
    	echo '</ul>';
    }
    ?>
    <form method="post">
    	<p>Getal voor de tafel van, standaard 7:<br /><input name="tafel" type="text" /></p>
        <p>Maximum aantal keer, standaard 10:<br /><input name="maximaal" type="text" /></p>
        <p><input name="verzenden" type="submit" value="Verzenden" /></p>
    </form>
    Toon Meer

    School
    Tweedejaars Informatica Student @ Hogeschool Rotterdam.

    Webtalen
    - PHP ( OOP )
    - SQL
    - JavaScript i.c.m. jQuery framework
    - (x)HTML
    - CSS
    - Actionscript
    - XML

    Programmeertalen
    - Java
    - C#
    - Ruby i.c.m. on Rails framework

Participate now!

Heb je nog geen account? Registreer je nu en word deel van onze community!

Maak een account aan Login

ICT Nieuws

  • Quanscient ontvangt €10M om AI- en kwantum-native hardware engineering te bevorderen - Tech.eu

    ICTscripters 27 mei 2026 om 12:03
  • Datalek bij leverancier Canvas - Universiteit van Amsterdam

    ICTscripters 10 mei 2026 om 12:03
  • Data privacy in 2026: Hoe de naleving van GDPR verandert

    ICTscripters 8 mei 2026 om 12:16

Blogs

  • Functioneel ontwerp

    Dees 28 december 2014 om 12:38
  • Access Control List implementatie in PHP/MySQL - deel 1/2

    FangorN 28 december 2018 om 12:35
  • Access Control List implementatie in PHP/MySQL - deel 2/2

    FangorN 29 december 2018 om 12:37
  1. Marktplaats
  2. Design
  3. Voorwaarden
  4. Ons team
  5. Leden
  6. Geschiedenis
  7. Regels
  8. Links
  9. Privacy Policy
ICTscripters ©2005 - 2026 , goedkope hosting door DiMoWeb.com, BE0558.915.582
Sponsors: Beste kattenhotel provincie Antwerpen | Beste Zetes eid kaartlezer webshop
Style: Nexus by cls-design
Stylename
Nexus
Manufacturer
cls-design
Licence
Commercial styles
Help
Supportforum
Visit cls-design