
( ! ) Notice: A non well formed numeric value encountered in /var/www/html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118 | ||||
---|---|---|---|---|
Call Stack | ||||
# | Time | Memory | Function | Location |
1 | 0.0002 | 395848 | {main}( ) | .../index.php:0 |
2 | 0.0002 | 396136 | require( '/var/www/html/wp-blog-header.php' ) | .../index.php:17 |
3 | 1.1220 | 12796568 | require_once( '/var/www/html/wp-includes/template-loader.php' ) | .../wp-blog-header.php:19 |
4 | 1.1300 | 12925944 | include( '/var/www/html/wp-content/themes/storefront/archive.php' ) | .../template-loader.php:98 |
5 | 1.2199 | 13345848 | get_template_part( ) | .../archive.php:25 |
6 | 1.2199 | 13346312 | locate_template( ) | .../general-template.php:168 |
7 | 1.2199 | 13346392 | load_template( ) | .../template.php:671 |
8 | 1.2200 | 13346680 | require( '/var/www/html/wp-content/themes/storefront/loop.php' ) | .../template.php:724 |
9 | 1.2206 | 13348184 | get_template_part( ) | .../loop.php:21 |
10 | 1.2206 | 13348656 | locate_template( ) | .../general-template.php:168 |
11 | 1.2206 | 13348736 | load_template( ) | .../template.php:671 |
12 | 1.2207 | 13354616 | require( '/var/www/html/wp-content/themes/storefront/content.php' ) | .../template.php:724 |
13 | 1.2222 | 13355368 | do_action( ) | .../content.php:19 |
14 | 1.2222 | 13355744 | WP_Hook->do_action( ) | .../plugin.php:478 |
15 | 1.2222 | 13355744 | WP_Hook->apply_filters( ) | .../class-wp-hook.php:312 |
16 | 1.2259 | 13359776 | storefront_post_content( ) | .../class-wp-hook.php:288 |
17 | 1.2301 | 13373848 | the_content( ) | .../storefront-template-functions.php:414 |
18 | 1.2301 | 13376240 | apply_filters( ) | .../post-template.php:253 |
19 | 1.2301 | 13376640 | WP_Hook->apply_filters( ) | .../plugin.php:206 |
20 | 1.2390 | 13389376 | CrayonWP::the_content( ) | .../class-wp-hook.php:288 |
21 | 1.2486 | 13468360 | CrayonHighlighter->output( ) | .../crayon_wp.class.php:703 |
22 | 1.2556 | 13545768 | CrayonFormatter::print_code( ) | .../crayon_highlighter.class.php:189 |
( ! ) Notice: A non well formed numeric value encountered in /var/www/html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119 | ||||
---|---|---|---|---|
Call Stack | ||||
# | Time | Memory | Function | Location |
1 | 0.0002 | 395848 | {main}( ) | .../index.php:0 |
2 | 0.0002 | 396136 | require( '/var/www/html/wp-blog-header.php' ) | .../index.php:17 |
3 | 1.1220 | 12796568 | require_once( '/var/www/html/wp-includes/template-loader.php' ) | .../wp-blog-header.php:19 |
4 | 1.1300 | 12925944 | include( '/var/www/html/wp-content/themes/storefront/archive.php' ) | .../template-loader.php:98 |
5 | 1.2199 | 13345848 | get_template_part( ) | .../archive.php:25 |
6 | 1.2199 | 13346312 | locate_template( ) | .../general-template.php:168 |
7 | 1.2199 | 13346392 | load_template( ) | .../template.php:671 |
8 | 1.2200 | 13346680 | require( '/var/www/html/wp-content/themes/storefront/loop.php' ) | .../template.php:724 |
9 | 1.2206 | 13348184 | get_template_part( ) | .../loop.php:21 |
10 | 1.2206 | 13348656 | locate_template( ) | .../general-template.php:168 |
11 | 1.2206 | 13348736 | load_template( ) | .../template.php:671 |
12 | 1.2207 | 13354616 | require( '/var/www/html/wp-content/themes/storefront/content.php' ) | .../template.php:724 |
13 | 1.2222 | 13355368 | do_action( ) | .../content.php:19 |
14 | 1.2222 | 13355744 | WP_Hook->do_action( ) | .../plugin.php:478 |
15 | 1.2222 | 13355744 | WP_Hook->apply_filters( ) | .../class-wp-hook.php:312 |
16 | 1.2259 | 13359776 | storefront_post_content( ) | .../class-wp-hook.php:288 |
17 | 1.2301 | 13373848 | the_content( ) | .../storefront-template-functions.php:414 |
18 | 1.2301 | 13376240 | apply_filters( ) | .../post-template.php:253 |
19 | 1.2301 | 13376640 | WP_Hook->apply_filters( ) | .../plugin.php:206 |
20 | 1.2390 | 13389376 | CrayonWP::the_content( ) | .../class-wp-hook.php:288 |
21 | 1.2486 | 13468360 | CrayonHighlighter->output( ) | .../crayon_wp.class.php:703 |
22 | 1.2556 | 13545768 | CrayonFormatter::print_code( ) | .../crayon_highlighter.class.php:189 |
( ! ) Notice: A non well formed numeric value encountered in /var/www/html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118 | ||||
---|---|---|---|---|
Call Stack | ||||
# | Time | Memory | Function | Location |
1 | 0.0002 | 395848 | {main}( ) | .../index.php:0 |
2 | 0.0002 | 396136 | require( '/var/www/html/wp-blog-header.php' ) | .../index.php:17 |
3 | 1.1220 | 12796568 | require_once( '/var/www/html/wp-includes/template-loader.php' ) | .../wp-blog-header.php:19 |
4 | 1.1300 | 12925944 | include( '/var/www/html/wp-content/themes/storefront/archive.php' ) | .../template-loader.php:98 |
5 | 1.2199 | 13345848 | get_template_part( ) | .../archive.php:25 |
6 | 1.2199 | 13346312 | locate_template( ) | .../general-template.php:168 |
7 | 1.2199 | 13346392 | load_template( ) | .../template.php:671 |
8 | 1.2200 | 13346680 | require( '/var/www/html/wp-content/themes/storefront/loop.php' ) | .../template.php:724 |
9 | 1.2206 | 13348184 | get_template_part( ) | .../loop.php:21 |
10 | 1.2206 | 13348656 | locate_template( ) | .../general-template.php:168 |
11 | 1.2206 | 13348736 | load_template( ) | .../template.php:671 |
12 | 1.2207 | 13354616 | require( '/var/www/html/wp-content/themes/storefront/content.php' ) | .../template.php:724 |
13 | 1.2222 | 13355368 | do_action( ) | .../content.php:19 |
14 | 1.2222 | 13355744 | WP_Hook->do_action( ) | .../plugin.php:478 |
15 | 1.2222 | 13355744 | WP_Hook->apply_filters( ) | .../class-wp-hook.php:312 |
16 | 1.2259 | 13359776 | storefront_post_content( ) | .../class-wp-hook.php:288 |
17 | 1.2301 | 13373848 | the_content( ) | .../storefront-template-functions.php:414 |
18 | 1.2301 | 13376240 | apply_filters( ) | .../post-template.php:253 |
19 | 1.2301 | 13376640 | WP_Hook->apply_filters( ) | .../plugin.php:206 |
20 | 1.2390 | 13389376 | CrayonWP::the_content( ) | .../class-wp-hook.php:288 |
21 | 1.2617 | 13659960 | CrayonHighlighter->output( ) | .../crayon_wp.class.php:703 |
22 | 1.2633 | 13592480 | CrayonFormatter::print_code( ) | .../crayon_highlighter.class.php:189 |
( ! ) Notice: A non well formed numeric value encountered in /var/www/html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119 | ||||
---|---|---|---|---|
Call Stack | ||||
# | Time | Memory | Function | Location |
1 | 0.0002 | 395848 | {main}( ) | .../index.php:0 |
2 | 0.0002 | 396136 | require( '/var/www/html/wp-blog-header.php' ) | .../index.php:17 |
3 | 1.1220 | 12796568 | require_once( '/var/www/html/wp-includes/template-loader.php' ) | .../wp-blog-header.php:19 |
4 | 1.1300 | 12925944 | include( '/var/www/html/wp-content/themes/storefront/archive.php' ) | .../template-loader.php:98 |
5 | 1.2199 | 13345848 | get_template_part( ) | .../archive.php:25 |
6 | 1.2199 | 13346312 | locate_template( ) | .../general-template.php:168 |
7 | 1.2199 | 13346392 | load_template( ) | .../template.php:671 |
8 | 1.2200 | 13346680 | require( '/var/www/html/wp-content/themes/storefront/loop.php' ) | .../template.php:724 |
9 | 1.2206 | 13348184 | get_template_part( ) | .../loop.php:21 |
10 | 1.2206 | 13348656 | locate_template( ) | .../general-template.php:168 |
11 | 1.2206 | 13348736 | load_template( ) | .../template.php:671 |
12 | 1.2207 | 13354616 | require( '/var/www/html/wp-content/themes/storefront/content.php' ) | .../template.php:724 |
13 | 1.2222 | 13355368 | do_action( ) | .../content.php:19 |
14 | 1.2222 | 13355744 | WP_Hook->do_action( ) | .../plugin.php:478 |
15 | 1.2222 | 13355744 | WP_Hook->apply_filters( ) | .../class-wp-hook.php:312 |
16 | 1.2259 | 13359776 | storefront_post_content( ) | .../class-wp-hook.php:288 |
17 | 1.2301 | 13373848 | the_content( ) | .../storefront-template-functions.php:414 |
18 | 1.2301 | 13376240 | apply_filters( ) | .../post-template.php:253 |
19 | 1.2301 | 13376640 | WP_Hook->apply_filters( ) | .../plugin.php:206 |
20 | 1.2390 | 13389376 | CrayonWP::the_content( ) | .../class-wp-hook.php:288 |
21 | 1.2617 | 13659960 | CrayonHighlighter->output( ) | .../crayon_wp.class.php:703 |
22 | 1.2633 | 13592480 | CrayonFormatter::print_code( ) | .../crayon_highlighter.class.php:189 |
( ! ) Notice: A non well formed numeric value encountered in /var/www/html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118 | ||||
---|---|---|---|---|
Call Stack | ||||
# | Time | Memory | Function | Location |
1 | 0.0002 | 395848 | {main}( ) | .../index.php:0 |
2 | 0.0002 | 396136 | require( '/var/www/html/wp-blog-header.php' ) | .../index.php:17 |
3 | 1.1220 | 12796568 | require_once( '/var/www/html/wp-includes/template-loader.php' ) | .../wp-blog-header.php:19 |
4 | 1.1300 | 12925944 | include( '/var/www/html/wp-content/themes/storefront/archive.php' ) | .../template-loader.php:98 |
5 | 1.2199 | 13345848 | get_template_part( ) | .../archive.php:25 |
6 | 1.2199 | 13346312 | locate_template( ) | .../general-template.php:168 |
7 | 1.2199 | 13346392 | load_template( ) | .../template.php:671 |
8 | 1.2200 | 13346680 | require( '/var/www/html/wp-content/themes/storefront/loop.php' ) | .../template.php:724 |
9 | 1.2206 | 13348184 | get_template_part( ) | .../loop.php:21 |
10 | 1.2206 | 13348656 | locate_template( ) | .../general-template.php:168 |
11 | 1.2206 | 13348736 | load_template( ) | .../template.php:671 |
12 | 1.2207 | 13354616 | require( '/var/www/html/wp-content/themes/storefront/content.php' ) | .../template.php:724 |
13 | 1.2222 | 13355368 | do_action( ) | .../content.php:19 |
14 | 1.2222 | 13355744 | WP_Hook->do_action( ) | .../plugin.php:478 |
15 | 1.2222 | 13355744 | WP_Hook->apply_filters( ) | .../class-wp-hook.php:312 |
16 | 1.2259 | 13359776 | storefront_post_content( ) | .../class-wp-hook.php:288 |
17 | 1.2301 | 13373848 | the_content( ) | .../storefront-template-functions.php:414 |
18 | 1.2301 | 13376240 | apply_filters( ) | .../post-template.php:253 |
19 | 1.2301 | 13376640 | WP_Hook->apply_filters( ) | .../plugin.php:206 |
20 | 1.2390 | 13389376 | CrayonWP::the_content( ) | .../class-wp-hook.php:288 |
21 | 1.2687 | 13657496 | CrayonHighlighter->output( ) | .../crayon_wp.class.php:703 |
22 | 1.2713 | 13606592 | CrayonFormatter::print_code( ) | .../crayon_highlighter.class.php:189 |
( ! ) Notice: A non well formed numeric value encountered in /var/www/html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119 | ||||
---|---|---|---|---|
Call Stack | ||||
# | Time | Memory | Function | Location |
1 | 0.0002 | 395848 | {main}( ) | .../index.php:0 |
2 | 0.0002 | 396136 | require( '/var/www/html/wp-blog-header.php' ) | .../index.php:17 |
3 | 1.1220 | 12796568 | require_once( '/var/www/html/wp-includes/template-loader.php' ) | .../wp-blog-header.php:19 |
4 | 1.1300 | 12925944 | include( '/var/www/html/wp-content/themes/storefront/archive.php' ) | .../template-loader.php:98 |
5 | 1.2199 | 13345848 | get_template_part( ) | .../archive.php:25 |
6 | 1.2199 | 13346312 | locate_template( ) | .../general-template.php:168 |
7 | 1.2199 | 13346392 | load_template( ) | .../template.php:671 |
8 | 1.2200 | 13346680 | require( '/var/www/html/wp-content/themes/storefront/loop.php' ) | .../template.php:724 |
9 | 1.2206 | 13348184 | get_template_part( ) | .../loop.php:21 |
10 | 1.2206 | 13348656 | locate_template( ) | .../general-template.php:168 |
11 | 1.2206 | 13348736 | load_template( ) | .../template.php:671 |
12 | 1.2207 | 13354616 | require( '/var/www/html/wp-content/themes/storefront/content.php' ) | .../template.php:724 |
13 | 1.2222 | 13355368 | do_action( ) | .../content.php:19 |
14 | 1.2222 | 13355744 | WP_Hook->do_action( ) | .../plugin.php:478 |
15 | 1.2222 | 13355744 | WP_Hook->apply_filters( ) | .../class-wp-hook.php:312 |
16 | 1.2259 | 13359776 | storefront_post_content( ) | .../class-wp-hook.php:288 |
17 | 1.2301 | 13373848 | the_content( ) | .../storefront-template-functions.php:414 |
18 | 1.2301 | 13376240 | apply_filters( ) | .../post-template.php:253 |
19 | 1.2301 | 13376640 | WP_Hook->apply_filters( ) | .../plugin.php:206 |
20 | 1.2390 | 13389376 | CrayonWP::the_content( ) | .../class-wp-hook.php:288 |
21 | 1.2687 | 13657496 | CrayonHighlighter->output( ) | .../crayon_wp.class.php:703 |
22 | 1.2713 | 13606592 | CrayonFormatter::print_code( ) | .../crayon_highlighter.class.php:189 |
( ! ) Notice: A non well formed numeric value encountered in /var/www/html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118 | ||||
---|---|---|---|---|
Call Stack | ||||
# | Time | Memory | Function | Location |
1 | 0.0002 | 395848 | {main}( ) | .../index.php:0 |
2 | 0.0002 | 396136 | require( '/var/www/html/wp-blog-header.php' ) | .../index.php:17 |
3 | 1.1220 | 12796568 | require_once( '/var/www/html/wp-includes/template-loader.php' ) | .../wp-blog-header.php:19 |
4 | 1.1300 | 12925944 | include( '/var/www/html/wp-content/themes/storefront/archive.php' ) | .../template-loader.php:98 |
5 | 1.2199 | 13345848 | get_template_part( ) | .../archive.php:25 |
6 | 1.2199 | 13346312 | locate_template( ) | .../general-template.php:168 |
7 | 1.2199 | 13346392 | load_template( ) | .../template.php:671 |
8 | 1.2200 | 13346680 | require( '/var/www/html/wp-content/themes/storefront/loop.php' ) | .../template.php:724 |
9 | 1.2206 | 13348184 | get_template_part( ) | .../loop.php:21 |
10 | 1.2206 | 13348656 | locate_template( ) | .../general-template.php:168 |
11 | 1.2206 | 13348736 | load_template( ) | .../template.php:671 |
12 | 1.2207 | 13354616 | require( '/var/www/html/wp-content/themes/storefront/content.php' ) | .../template.php:724 |
13 | 1.2222 | 13355368 | do_action( ) | .../content.php:19 |
14 | 1.2222 | 13355744 | WP_Hook->do_action( ) | .../plugin.php:478 |
15 | 1.2222 | 13355744 | WP_Hook->apply_filters( ) | .../class-wp-hook.php:312 |
16 | 1.2259 | 13359776 | storefront_post_content( ) | .../class-wp-hook.php:288 |
17 | 1.2301 | 13373848 | the_content( ) | .../storefront-template-functions.php:414 |
18 | 1.2301 | 13376240 | apply_filters( ) | .../post-template.php:253 |
19 | 1.2301 | 13376640 | WP_Hook->apply_filters( ) | .../plugin.php:206 |
20 | 1.2390 | 13389376 | CrayonWP::the_content( ) | .../class-wp-hook.php:288 |
21 | 1.2772 | 13679800 | CrayonHighlighter->output( ) | .../crayon_wp.class.php:703 |
22 | 1.2783 | 13608640 | CrayonFormatter::print_code( ) | .../crayon_highlighter.class.php:189 |
( ! ) Notice: A non well formed numeric value encountered in /var/www/html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119 | ||||
---|---|---|---|---|
Call Stack | ||||
# | Time | Memory | Function | Location |
1 | 0.0002 | 395848 | {main}( ) | .../index.php:0 |
2 | 0.0002 | 396136 | require( '/var/www/html/wp-blog-header.php' ) | .../index.php:17 |
3 | 1.1220 | 12796568 | require_once( '/var/www/html/wp-includes/template-loader.php' ) | .../wp-blog-header.php:19 |
4 | 1.1300 | 12925944 | include( '/var/www/html/wp-content/themes/storefront/archive.php' ) | .../template-loader.php:98 |
5 | 1.2199 | 13345848 | get_template_part( ) | .../archive.php:25 |
6 | 1.2199 | 13346312 | locate_template( ) | .../general-template.php:168 |
7 | 1.2199 | 13346392 | load_template( ) | .../template.php:671 |
8 | 1.2200 | 13346680 | require( '/var/www/html/wp-content/themes/storefront/loop.php' ) | .../template.php:724 |
9 | 1.2206 | 13348184 | get_template_part( ) | .../loop.php:21 |
10 | 1.2206 | 13348656 | locate_template( ) | .../general-template.php:168 |
11 | 1.2206 | 13348736 | load_template( ) | .../template.php:671 |
12 | 1.2207 | 13354616 | require( '/var/www/html/wp-content/themes/storefront/content.php' ) | .../template.php:724 |
13 | 1.2222 | 13355368 | do_action( ) | .../content.php:19 |
14 | 1.2222 | 13355744 | WP_Hook->do_action( ) | .../plugin.php:478 |
15 | 1.2222 | 13355744 | WP_Hook->apply_filters( ) | .../class-wp-hook.php:312 |
16 | 1.2259 | 13359776 | storefront_post_content( ) | .../class-wp-hook.php:288 |
17 | 1.2301 | 13373848 | the_content( ) | .../storefront-template-functions.php:414 |
18 | 1.2301 | 13376240 | apply_filters( ) | .../post-template.php:253 |
19 | 1.2301 | 13376640 | WP_Hook->apply_filters( ) | .../plugin.php:206 |
20 | 1.2390 | 13389376 | CrayonWP::the_content( ) | .../class-wp-hook.php:288 |
21 | 1.2772 | 13679800 | CrayonHighlighter->output( ) | .../crayon_wp.class.php:703 |
22 | 1.2783 | 13608640 | CrayonFormatter::print_code( ) | .../crayon_highlighter.class.php:189 |
The factory design pattern solves a common programming problem. When you have a single point of origin for many classes with the same base class, you have need of the factory design pattern. A factory is a class that instantiates one or more of a number of classes that share the same base type, choosing the type of the instantiated object type at runtime without exposing the instantiation logic. You won’t often see this pattern appearing in basic projects, but as you move into enterprise development, it is very common.
In the following example, an object of type ShapeFactory is instantiated by the application code. Then when the getShape() method is called, the ShapeFactory object instantiates a new object which based on the logic in this function chooses which child class of the Shape class will be chosen to hold the new object. This allows a little more freedom in which types we use at runtime.

Factory Design Pattern Example In PHP
The factory design pattern is very simple. The simplest example I like to use to describe it using PHP is a basic game with different kinds of enemy ships. In the following example we will start with an enemy class, and a few child classes that extend it like so:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
<?php class enemy{ public $name; public $damage; public $speed; public function dostuff(){ echo "$name enters going $speed and attacks doing $damage damage"; } } class SmallShip extends enemy{ public function __construct(){ $this->name= 'small ship'; $this->damage= 10; $this->speed= 10; } } class MediumShip extends enemy{ public function __construct(){ $this->name= 'medium ship'; $this->damage= 15; $this->speed= 15; } } class LargeShip extends enemy{ public function __construct(){ $this->name= 'large ship'; $this->damage= 25; $this->speed= 25; } } |
Now if we are playing a game and wanted to call any of the enemy ship types from a single point of origin, we would spawn them using a factory class that looks something like this:
1 2 3 4 5 6 7 |
<?php class ShipFactory{ public function NewShip($type='SmallShip'){ $ship = new $type(); $ship->dostuff(); } } |
The code that calls the factory looks like this:
1 2 3 4 5 6 7 8 9 10 |
<?php $s = new ShipFactory(); $ships = array(); $ships[] = $s->NewShip('SmallShip'); $ships[] = $s->NewShip('MediumShip'); $ships[] = $s->NewShip('LargeShip'); foreach($ships as $ship){ echo $ship->doStuff(); echo "<br>"; } |
With output looking like this:
1 2 3 |
small ship enters going 10 and attacks doing 10 damage medium ship enters going 15 and attacks doing 15 damage large ship enters going 25 and attacks doing 25 damage |