Comparison Operators

PHP comparison operators allows you to compare two values with each other. Below is a table of all the different comparison operators that are available for PHP Comparison Operators Example Name Result $a == $b Equal TRUE if $a is equal to $b. $a === $b Identical TRUE if $a is equal to $b, and they are of the same type. (introduced in PHP 4) $a != $b Not equal TRUE if $a is not equal to $b. $a <> $b Not equal TRUE if $a is not equal to $b. $a !== $b Not identical TRUE if $a is not equal to $b, or they are not of the same type. (introduced in PHP 4) $a < $b Less than TRUE if $a is strictly less than $b. $a > $b Greater than TRUE if $a is strictly greater than $b. $a <= $b Less than or equal to TRUE if $a is less than or equal to $b. $a >= $b Greater than or equal to TRUE if $a is greater than or equal to $b.

March 22, 2018 · 1 min · 178 words · icarnaghan

Creating Superscripted text in HTML

Superscripted text can be used on your website by placing text between the tag Superscripted text comes in handy to express exponential expressions eg 23 = 8or footnotes to draw attention. By placing the th between the tag 5th becomes 5th

March 22, 2018 · 1 min · 41 words · icarnaghan

Disabling the Layout and the View in cakePHP

To disable the view and the layout in cakePHP set autoRender to false within the appropriate action in your controller $this->autoRender = false; To only disable the layout in cakePHP set the layout to false $this->layout = false; And to only disable the view for an action call the render method and set the parameter to false $this->render(false);

March 22, 2018 · 1 min · 58 words · icarnaghan

Error 400: The CSRF token could not be verified

Getting Error 400: The CSRF token could not be verified. when trying to delete an item using the default delete link. $this->menu=array( array(’label’=>‘Create Use’, ‘url’=>array(‘create’)), array(’label’=>‘Update Use’, ‘url’=>array(‘update’, ‘id’=>$model->use_id)), array(’label’=>‘Delete Use’, ‘url’=>’#’, ’linkOptions’=>array(‘submit’=>array(‘delete’,‘id’=>$model->use_id,‘confirm’=>‘Are you sure you want to delete this item?’)), array(’label’=>‘Manage Uses’, ‘url’=>array(‘admin’)), ); Answer: This problem can be solved by adding ‘csrf’ => true to the linkOptions $this->menu=array( array(’label’=>‘Create Use’, ‘url’=>array(‘create’)), array(’label’=>‘Update Use’, ‘url’=>array(‘update’, ‘id’=>$model->use_id)), array(’label’=>‘Delete Use’, ‘url’=>’#’, ’linkOptions’=>array(‘submit’=>array(‘delete’,‘id’=>$model->use_id,‘confirm’=>‘Are you sure you want to delete this item?’),‘csrf’=>true)), array(’label’=>‘Manage Uses’, ‘url’=>array(‘admin’)), );

March 22, 2018 · 1 min · 83 words · icarnaghan

Getting error: Bad Request The CSRF token could not be verified: when CSRF has been enabled in the Yii Framework

Getting error: Bad Request The CSRF token could not be verified: when CSRF has been enabled in the Yii Framework and I’m clicking on a linkButton within a form. Add ‘YII_CSRF_TOKEN’ => Yii::app()->request->csrfToken to the params array in the linkButton Example <?php echo CHtml::linkButton('Register', array('submit' => ' ', 'params' => array('reg'=>'new', 'YII_CSRF_TOKEN' => Yii::app()->request->csrfToken ), )); ?>

March 22, 2018 · 1 min · 57 words · icarnaghan

Getting PHP Fatal error: Can't use function return value in write context

Make sure that you did not include a function within the empty PHP function. eg if(empty(getUsers())){}

March 22, 2018 · 1 min · 16 words · icarnaghan

Getting Warning: split(): REG_BADRPT when using the split PHP function

Getting Warning: split(): REG_BADRPT when using the split PHP function when I try to split a string after each question mark (?). E.g. $string = "ABC?DEF?BGT"; list($a,$b) = split('?',$string); Answer: The reason why this is failing is split gives you the power to use regular expressions Use the explode() function instead If you really need to use the split() function try escaping the character eg. ’/\?/’

March 22, 2018 · 1 min · 66 words · icarnaghan

How to add a Google Map to your mobile website

First of all we can only use a static map, since Google Maps uses Javascript to zoom etc and most phones on the market do not support Javascript, so the only solution is to use static maps. Before we can use the Google Maps API we need to apply for an Application Key by visiting this URL http://code.google.com/apis/maps/signup.html Now use the following code within an HTML img tag <img src="http://maps.google.com/maps/api/staticmap?center=ADDRESS&zoom=14&size=150x150&sensor=false&markers=color:blue|ADDRESS&maptype=roadmap&mobile=true&key=APPLICATION_KEY" alt="Google Map" /> Replace ADDRESS with you address Replace APPLICATION_KEY with your application key, obtained from http://code.google.com/apis/maps/signup.html ...

March 22, 2018 · 1 min · 103 words · icarnaghan

How to add JavaScript to you view files using the Yii Framework

Add the JavaScript code as below to your view $js = Yii::app()->getClientScript(); $js->registerScript( 'my-javascript-id', 'var value = "Hello World"; alert(value);', CClientScript::POS_END ); Yii’s CClientScript is used to place JavaScript to your views. The arguments of register script are as follows: The first argument uniquely identifies your script The second argument contains your actual JavaScript The third argument sets the position where the JavaScript should be placed. In the example above the CClientScript::POS_END specifies that the script will be placed before the closing tag. More details about registerScript can be found here

March 22, 2018 · 1 min · 91 words · icarnaghan

How to add months to a given date using PHP

By using the PHP functions date and strtotime this can be accomplished. Example $date = '2010-03-22'; $new_date = date('Y-m-d',strtotime('+4 months',strtotime($date))); echo $new_date; //Displays 2010-07-22 Explanation of PHP functions: 1) FUNCTION date DESCRIPTION string date ( string $format [, int $timestamp ] ) PARAMETERS USED IN THIS EXAMPLE Y = A full numeric representation of a year, 4 digits (Examples: 1999 or 2003) m = Numeric representation of a month, with leading zeros (01 through 12) d = Day of the month, 2 digits with leading zeros (01 to 31) ...

March 22, 2018 · 1 min · 141 words · icarnaghan