Internet explorer – remove border around image link

If you want to completely remove Internet Explorer border around images that are links, use the following CSS code.

a img {
    border-width: 0px;
}
Posted in CSS | 2 Comments

Special characters in PHP exported CSV

When creating a CSV file with the special characters, be sure to encounter the problem of encoding characters. Although the output is in UTF-8 OK, Microsoft Excel displays the wrong characters. The solution is simple and is called BOM. At the beginning of the file just add the BOM characters, indicating that the file is in the character set UTF-8.

Solution:

$ document = chr (0xEF). chr (0xBB). chr (0xBF). $ csvContent;

Variable csvContent contains the contents of the CSV document. The variable document is a content of CSV dates, you just need to write to a file.

Posted in PHP | Leave a comment

String contains another string

In this paper, I will bring a simple command (condition) in PHP to check whether a string contains another string. Unfortunately, PHP don’t have function contains, and we must create it yourself.

1st Testing whether a string contains a substring.

if (strpos($retezec,$hledany_vyraz) !== false) {
    echo 'String found';
}

2nd The condition whether a string contains a given substring.

if (strpos($retezec,$hledany_vyraz) === false) {
    echo 'String not found';
}

3rd A comprehensive test on the contents of the substring in string

if (strpos($retezec,$hledany_vyraz) === false) {
    echo 'string not found';
}  else {
    echo 'string found';
}

How does it works?
strpos returns the position of substring in the text. If the text does not contains substring, it returns false. As can be just the substring in the first place, you must use == instead of === operator (or !==).

Important Notice! Do not use for test commands strstr or ereg! Both commands are too computationally and memory intensive.

Posted in PHP | Leave a comment

Current page URL

Often it is necessary for PHP to find out what is the URL of the currently displayed page. If you are using only HTTP and not using a different port number than 80, you can use the following code:

$pageURL = "http://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];

If you are using HTTPS or port numbers, you can use the following more complex script:

$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {
     $pageURL .= "s";
}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
     $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
     $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
Posted in PHP | Leave a comment

Debugging JavaScript

The basic of the debugging is printing variables. But how to write such an object in JavaScript? Just write a simple code:

console.debug (variable)

Variable content appears in the console.

How to display console in Firefox?

  1. Install Firebug extension
  2. Right-click anywhere on the page
  3. Select “element to examine”

How to display console in Google Chrome?

  1. Right-click anywhere on the page
  2. Select “check control”
Posted in JavaScript | Leave a comment

Absolute positioning – where is 0,0?

There are many tutorials on CSS positioning. In short, there are three modes:

  • static
  • relative
  • absolute

In static mode, the element is located where it should normally be.

In relative mode is the position set by the parent element.

And how is it in absolute positioning? In absolute mode, positioning is from the nearest parent tag that has set the relative positioning or absolute.

Interesting tutorial: http://www.barelyfitz.com/screencast/html-training/css/positioning/

Posted in CSS | Leave a comment

How to close JFrame from code

The close () in JFrame unfortunately does not exist. Nevertheless, we can easily form close.

jFrameInstance.setVisible(false);

or

jFrameInstace.dispose();

The first method described only invisible form. We can work with him in the future. The second method invisible form and releases all used resources.

Posted in Java | Leave a comment

Printf doesn’t print anything

In this post, some advise for beginners.

Do you need print some debug info using printf and it print at the wrong time or does not print nothing? Don’t remember to flush the buffer, which is in the output. You have to use command fflush ().

Printf ("Some debug information");
fflush (stdout);

Stdout is the abbreviation for the standard output to the console. Fflush command can be used when working with files too. In this case, with variable of type FILE *.

Posted in C/C++ | Leave a comment

Execute an exception (call an exception)

Do you need execute an exception? Just use a simple code:

throw new SQLException();

or for example:

throw new NullPointerException();
Posted in Java | Leave a comment

Conversion BigDecimal to Integer

Very simple:

int myInt = myBigDecimal.intValue();
Posted in Java | Leave a comment