Posts

Showing posts with the label PHP

Absolutely Position Element Within a Table Cell

Image
Absolutely Position Element Within a Table Cell   Have you ever wanted to absolutely or relatively position a table cell? Well, I can't help you there. Table cell elements just won't take those position values. And thus, you also can't absolutely position elements within the context of those elements either. I can help you out with that issue. The answer is just to make a generic wrapper element inside the table cells (the exact same size of the table cell) and use that as the relative positioning context. Non-semantic? Yep, but we'll chuck that markup in with JavaScript so it's not a big deal. Kludgy fix? You know it. Does it work? Sure does. # Before < table > < tr > < td > < img src = " yay.jpg " alt = " " > </ td > </ tr > </ table > # After < table > < tr > < td > < div class = " innerWrapper " > <!-- appen...

A beginner’s guide to writing title tags and meta descriptions that get clicks

Image
A beginner’s guide to writing title tags and meta descriptions that get clicks It’s true: title tags and meta descriptions won’t help your website magically rise to the top of the search engine results. Google confirmed it back in 2007 so let’s kill that myth right at the outset. However, these two elements can improve click through rates and entice people to click on your link rather than the link of one of your competitors. So why do site owners neglect title tags and meta descriptions, pushing them to the back burner? Title tags and descriptions tell search engines and users what your site is about. They describe the content on each page of your website and explain how it relates to a user’s search query. And, when used properly, they can act as a “hook” of your advertising in the search engine results. If you don’t know what title tags and meta descriptions are, why they’re important and how to write them to get more prospects to click on your links in search engine results, we’ll...

How To Use HTML Meta Tags

Image
Want top search engine rankings? Just add meta tags and your website will magically rise to the top, right? Wrong. Meta tags are one piece in a large algorithmic puzzle that major search engines look at when deciding which results are relevant to show users who have typed in a search query. While there is still some debate about which meta tags remain useful and important to search engines, meta tags definitely aren’t a magic solution to gaining rankings in Google, Bing, Yahoo, or elsewhere – so let’s kill that myth right at the outset. However, meta tags help tell search engines and users what your site is about, and when meta tags are implemented incorrectly, the negative impact can be substantial and heartbreaking. Let’s look at what meta tags are, what meta tags matter, and how to avoid mistakes when implementing meta tags on your website. What Are Meta Tags? HTML meta tags are officially page data tags that lie between the open and closing head tags in the HTML code of a document....

Meta tags that Google understands

Meta tags that Google understands Meta tags are a great way for webmasters to provide search engines with information about their sites. Meta tags can be used to provide information to all sorts of clients, and each system processes only the meta tags they understand and ignores the rest. Meta tags are added to the <head> section of your HTML page and generally look like this: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="Description" CONTENT="Author: A.N. Author, Illustrator: P. Picture, Category: Books, Price: £9.24, Length: 784 pages"> <meta name="google-site-verification" content="+nxGUDJ4QpAZ5l9Bsjdi102tLVC21AIh5d1Nl23908vVuFHs34="/> <title>Example Books - high-quality used books for children</title> <meta name="robots" content="noindex,nofollow"> Google understands the following meta tags (and related items): ...
  The Table Class provides functions that enable you to auto-generate HTML tables from arrays or database result sets. Initializing the Class Like most other classes in CodeIgniter, the Table class is initialized in your controller using the $this->load->library function: $this->load->library('table'); Once loaded, the Table library object will be available using: $this->table Examples Here is an example showing how you can create a table from a multi-dimensional array. Note that the first array index will become the table heading (or you can set your own headings using the set_heading() function described in the function reference below). $this->load->library('table'); $data = array( array('Name', 'Color', 'Size'), array('Fred', 'Blue', 'Small'), array('Mary', 'Red', 'Large'), array('John', 'Green', 'Medium') ); echo $this->table->generate($data)...

PHP Tutorial - PHP Constants

Image
Constants are used to make sure a value does not change throughout the running of the script. Syntax To define a constant, use the define() function, and include name of the constant, followed by the value for the constant, as shown here: define( "MY_CONSTANT", "1" ); // MY_CONSTANT always has the string value "1" Note Constants may only contain scalar values such as Boolean, integer, float, and string (not values such as arrays and objects). Constants can be used from anywhere in your PHP program without regard to variable scope. Constants are case-sensitive. Example 1 <?PHP define( "aValue" , 8); print aValue; ?> The code above generates the following result. Example 2 Pass in true as a third parameter to define() makes the constant case-insensitive: <?PHP/* w ww .ja va2s . co m*/ define( "SecondsPerDay" , 86400, true); print SecondsPerDay; print SECONDSperDAY; ?> The code above generates the following resul...

PHP Tutorial - PHP String

Image
A string variable is created using quotation. In PHP we have two syntax to define strings $myString = 'string value'; or $myString = "string value"; The first form uses the single quotation and the second form uses the double quotation. The following code creates a string in PHP. <?PHP $myString = 'hello from java2s.com' ; print($myString); ?> The code above generates the following result. Double Quote In this example, the string literal is enclosed in single quotation marks ( ' ). You can also use double quotation marks ( " ), as follows: <?PHP $myString = "hello from java2s.com" ; print($myString); ?> The code above generates the following result. Multline strings To specify multline strings in PHP, insert newlines into the string literal between the quotation marks: <?PHP $myString = " demo from java2s.com "; echo $myString; ?> The code above generates the following result. PHP Single v...

PHP Tutorial - PHP Number Convert

Image
Convert a hexadecimal number to octal number The following code shows how to convert a hexadecimal number to octal number. // w ww. ja v a 2 s.c o m <?php $hex = "E196" ; echo base_convert($hex,16,8); ?> The code above generates the following result. Convert decimal number to binary number The following code shows how to convert decimal to binary. /*from w w w .j a v a 2s . c o m*/ <?php echo decbin( "3" ) . "<br>" ; echo decbin( "1" ) . "<br>" ; echo decbin( "2014" ) . "<br>" ; echo decbin( "7" ); ?> The code above generates the following result. Convert decimal to hexadecimal The following code shows how to convert decimal to hexadecimal. /*ww w . j a v a2 s. c om*/ <?php echo dechex( "30" ) . "<br>" ; echo dechex( "10" ) . "<br>" ; echo dechex( "2014" ) . "...

PHP Tutorial - PHP Integer

Image
Integers hold whole numbers, either positive or negative, such as 1, -20, 12345,etc. The limit of integer is between -2147483647 and 2147483647. The integer numbers outside the range are automatically converted to floats. The following code adds two integer values together in PHP. <?php /* w w w. j a v a 2 s.com*/ $var1 = 5; $var2 = 2; $answer = $var1 + $var2; print "$var1 plus $var2 equals $answer." ; ?> The code above generates the following result. PHP integer Literal We may specify integers in hexadecimal (base 16) or octal (base 8). The octal number system only uses the digits 0 to 7. hexadecimal uses 0 to 9, then A, B, C, D, E, and F. To specify number in octal, we must precede it with a 0 (zero). <?PHP $octalnum = 06331; print $octalnum; ?> The code above generates the following result. Hexadecimal To specify a number in hexadecimal, precede it with 0x . <?PHP $hexnum = 0x44; print $hexnum; ?> The code above generates the following result. Examp...

PHP Tutorial - PHP Boolean

Image
Booleans hold either true or false. Behind the scenes, booleans are integers. false value In addition, PHP considers the following values to be false : The literal value false The integer zero (0) The float zero ( 0.0 ) An empty string ( " " ) The string zero ( "0" ) An array with zero elements The special type null (including any unset variables) A SimpleXML object that is created from an empty XML tag All other values are considered true in a Boolean context. We can assign true or false value to a boolean type variable. <?PHP/* w w w . j av a2 s . c o m*/ $bool = true; print "Bool is set to $booln" ; $bool = false; print "Bool is set to $booln" ; ?> The code above generates the following result. Example 2 In the second if statement we compare the integer value to a boolean value. <?PHP/* w w w .j a va 2 s . c o m*/ $a=100; if ($a==100) { echo "the variable equals 1!n" ; } if ($a=...

Tutorial - PHP Data Types

Image
PHP has seven data types. The seven types are: string, integer, float, boolean, array, object, and resource. String Strings hold characters such as "a," "abc," "www.java2s.com," etc. PHP strings are case-sensitive. Object Objects are complex variables that have multiple values, and they can have their own functions. Resource Resources might be picture data, or the result of an SQL query. We should free up resources after using them. PHP References Reference type variables are actually pointer to the real data. Once two variables are pointing to the same data, you can change either variable and the other one will also update. When you use the = (assignment) operator, PHP takes the value from operand two and copies it into operand one. Syntax To assign by reference, you need to use the reference operator ( & ) after the equals operator (=), giving =& . Example <?PHP/*from w w w . j av a2 s . com*/ $a = 10; $b =& $a; ...

PHP Tutorial - PHP Introduction

Image
» PHP scripts are generally saved with the file extension .php . Statement The basic unit of PHP code is called a statement, which ends with a semicolon. Usually one line of code contains just one statement, but we can have as many statements on one line as you want. PHP Opening and Closing Code Islands <?php and ?> marks the PHP code island. The short tags version is <? and ?> . <?="Hello, world!" ?> Here is the equivalent, written using the standard open and closing tags: <?php print "Hello, world!" ; ?> Example - PHP Statements The following PHP code uses print statement to output message on to the screen. <?php // option 1 print "Hello, " ; print "world!" ; // option 2 print "Hello, " ; print "world!" ; ?> The code above generates the following result. echo is another command we can use to output message. echo is more useful because you can pass ...

PHP Tutorial - PHP basename() function

Image
Definition To get the filename part of a path, you can use the basename() function. Syntax PHP basename() function has the following syntax. basename(filePath,extension) Parameter PHP basename() function takes a path as its first parameter and, optionally, an extension as its second parameter. Return The return value is the name of the file without the directory information. If the filename has the same extension as specified, the extension is taken off also. Example Get the filename part of a path <?PHP//from ww w .j a v a 2 s.com $filename = basename( "/home/somefile.txt" ); echo $filename . "n" ; $filename = basename( "/home/somefile.txt" , ".php" ); echo $filename . "n" ; $filename = basename( "/home/somefile.txt" , ".txt" ); echo $filename . "n" ; ?> The code above generates the following result.

PSD to HTML Tutorial: The Only Guide You Need in 2016 video

Image
+ This article is supposed to be your ultimate PSD to HTML learning resource. We have more than 5 unique text and video coding tutorials in this article as well as additional 30 3rd-party PSD to HTML conversion tutorials. You will learn how to create HTML websites and convert your Photoshop designs in no time! At the end of article, we also included more tutorial sites you can use to deepen your coding knowledge. We have lots of different coding tutorials here, but let me start with the most complete video tutorial series, that will teach you how to design a website in Photoshop. Then you will learn how to convert this Photoshop design into HTML. And finally after we are done with HTML coding part, we’ll teach you how to convert into working Twitter Bootstrap website! As you can see everything you need is here. Note: If you don’t want to spend all the time learning how to do PSD to HTML conversion, check out a service PSD2HTML , which does it for you! Great if you are in rush, or if yo...