• 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

  • Na 15 jaar terug van weggeweest: iCriminals.nl is terug (BETA)!

    Syntax 23 december 2025 om 16:43
  • Developer Gezocht

    tcbhome 21 december 2025 om 15:07
  • Op zoek naar de legends

    Jeffrey.Hoekman 9 december 2025 om 09:41
  • [FREE] WeFact Hosting module

    Jeroen.G 13 oktober 2025 om 14:09
  • Help testers nodig voor android app Urgent

    urgentotservices 26 september 2025 om 10:21
  • Versio vervanger

    Jeroen.G 25 augustus 2025 om 15:56
  • Afspraken systeem met planbeperking

    Lijno 1 augustus 2025 om 23:04
  • Partner Gezocht om meerdere NFT Collecties op Open Sea te Plaatsen

    NFT Art Designer 1 maart 2025 om 14:08

Marktplaats

  • Meerdere mafia game template te koop

    Syntax 28 december 2025 om 21:20
  • Van een pixelige afbeelding naar een strakke, moderne website

    Syntax 21 december 2025 om 17:05
  • 302 Nieuwe Domeinnamen November 2025

    shiga 1 december 2025 om 13:07

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

  • 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

  • Fijne feestdagen

    tcbhome 28 december 2025 om 13:55
  • Kritieke update voor Really Simple Security-plug-in

    K.Rens 16 november 2024 om 16:12
  • ING Nederland streeft naar ondersteuning van Google Pay tegen eind februari

    K.Rens 2 november 2024 om 16:09

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

Gebruikers die dit topic bekijken

  • 1 Gasten
  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