Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

PHP redirect 301 example code


AD MOB

Example code



header("HTTP/1.1 301 Moved Permanently");
header("Location: https://www.newsite.com/new-page.php");
header("Connection: close");
exit();

If using file name without .php as part of smoothly url - example:


$fileName = basename(__FILE__, '.php');
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://www.mysite.cz/auto-moto/".$fileName."/");
header("Connection: close");
exit();

Date: 23.07.2020 - 12:31

76LW NO topic_id




AD

Další témata ....(Topics)


58

javascript Kopírování textu - zabránění | javascript-kopirovani-textu-zabraneni


Jak zabránit kopírování textu stránky v prohlížeči.


Do tagu body vložíme následující eventy:
oncontextmenu="return false" onmousedown="return false" onselectstart="return false" ondragstart="return false"

Tag body by mohl vypadat následovně:

<body oncontextmenu="return false" onmousedown="return false" onselectstart="return false" ondragstart="return false">
48

javascript Collapsible div | javascript-collapsible-div


Toogle DIV javascript example code:

Jak skrýt, nebo zobrazit kontejner DIV:
Nezapomeňte přiřadit DIVu ID, aby k němu bylo možno přistupovat pomocí getElementById a vše fungovalo i v jiných prohlížečích (Opera, Firefox, Google Chrome) a ne jen v Internet Exploreru.

<div id="idSomeDiv"> text div </div>


<input type="button" size="200" value="Skryj-zobraz" 
onclick="var dH = document.getElementById('idSomeDiv'); 
if(dH.style.visibility == 'hidden') { 
dH.style.visibility = 'visible'; 
} else { 
dH.style.visibility = 'hidden'; 
}">

34

PHP get variable type php | php-get-variable-type-php


php bývá vyčítano, že proměnné jsou typově nejednoznačné. To je sice pravda, ale php má funkci, která vrátí typ proměnné v dané části kodu.


$var = 10;   
// funkce  gettype vrací retezec s nazvem typu
// tak, jak jej vydi prekladac pri linkovani kodu  
$s = gettype($var); // $s == 'integer'   
  
$var = 'some text';   
$s = gettype($var); // $s == 'string'   
  
$var = 10.1;   
$s = gettype($var); // $s == 'double' 

50

javascript Textarea selection | javascript-textarea-selection


Textarea selection - získání pozice karety kurzoru.


     // FOR Gecko Browser selectionStart / selectionEnd selection length
 function getPos(){
     if	(typeof document.getElementById('idTextarea').selectionStart != 'undefined') {
        var nPosCursor = document.getElementById('idTextarea').selectionStart; 
        var nEndPos = document.getElementById('idTextarea').selectionEnd;
   return nPosCursor; 
   }
   return 0; // or -1 
}

// source by javascript-array.com/guides/javascript_faq/
//Internet Explorer 4+, Mozilla/Gecko/Firefox
function getCaretPos(obj)
{
  obj.focus();
  
  if(obj.selectionStart) return obj.selectionStart; //Gecko
  else if (document.selection) //Internet Explorer
  {
    var sel = document.selection.createRange();
    var clone = sel.duplicate();
    sel.collapse(true);
    clone.moveToElementText(obj);
    clone.setEndPoint('EndToEnd', sel);
    return clone.text.length;
  }
  
  return 0;
}

72

JavaScript Math functions examples | javascript-math-functions-constans-examples


List of usefull JavaSript functions and constans


var 1_radian_to_degree = 180 / Math.PI; // 57,295779513082320876798154814105 degree
var 1_degree_to_radian = Math.PI / 180; // 0,01745329251994329576923690768489 radian
var 360_degree =  2 * Math.PI * 1_radian_to_degree;

parseInt("10.33") // returns 10 string to integer
parseFloat("10.33") // returns 10.33 string to float

// change sign
var a = -1;
a = a * -1; // +1
// random sign
a *= Math.floor(Math.random()*2) == 1 ? 1 : -1; 


var who_is = 58;
var type = (typeof who_is); // number

Math.E  // natural logarithms, e, approximately 2.718281828459045
Math.LN10 // natural logarithm of 10, approximately 2.302585092994046
Math.LN2 // natural logarithm of 2, approximately 0.6931471805599453
Math.PI // approximately 3.141592653589793
Math.SQRT1_2 // square root of 1/2 which is approximately 0.7071067811865476
Math.SQRT2 // square root of 2, approximately 1.4142135623730951
Math.pow(4, 2) = 16 // 4 x 4 ... base 4 to the exponent 2 power
Math.abs(-5) absolute value of a number // return 5

Math.tan(degrees * Math.PI / 180) // get tangent from degrees
Math.tan(degree * Math.PI / 180)*adjacent = opposite
opposite / Math.tan(degree * Math.PI / 180) = adjacent
Math.acos(adjacent / hypotenuse) // angle of a right-angle triangle in radians
Math.atan(opposite / adjacent) // angle of a right-angle triangle in radians
var adjacent = Math.cos(radian) * hypotenuse; // leng of adjacent side 
// find the point on a circle if you know the circle´s radius
var x = Math.cos(pointAngleInRadiansFromCentreOfCircle) * radius;
var y = Math.sin(pointAngleInRadiansFromCentreOfCircle) * radius;

Math.cbrt(64) //  cube root of a number 4 (4 x 4 x 4)
Math.exp(xNumber) // returns e<sup>xNumber</sup> ... e == Math.E 


Math.ceil() // always rounds a number up to the next largest integer
Math.ceil(1.001) // 2

Math.floor() // returns largest integer less than or equal to a given number
Math.floor(5.85) = 5
Math.floor(-5.15) = -6

const arrayA = [2, 3, 1];
Math.min(...arrayA) = 1;
Math.max(1, 3, 2) = 3;

Math.random() // returns 0.000.... - 0.99999999999
Math.random() * 3 // returns 0.000 - 2.99999999999

Math.round() // returns value of a number rounded to the nearest integer.
Math.round(0.9) // 1
Math.round(5.5) // 6
Math.round(5.05) // 5 

Math.floor(Math.random() * 3) // returns 0, 1, 2



Date: 14.06.2020 - 08:38


Editace: 23.7.2020 - 12:39
Počet článků v kategorii: 76
Url:php-redirect-301-example-code

AD
11 Share
Share
Tweet