Jump to content
php.lv forumi

if else


gkazhus

Recommended Posts

Apmēram šādi

$regExpr = "http://";
$look = preg_match("/".$regExpr."/", $_POST["fname"]);
if($look == false) {
$link_URL = "http://" . $_POST["fname"]; 
} else {
$link_URL = $_POST["fname"];
}
echo $link_URL;

Edited by m8t
Link to comment
Share on other sites

Apmēram šādi

$regExpr = "http://";
$look = preg_match("/".$regExpr."/", $_POST["fname"]);
if($look == false) {
$link_URL = "http://" . $_POST["fname"]; 
} else {
$link_URL = $_POST["fname"];
}
echo $link_URL;

 

 

 

Lielais paldies nostraadaaja! Tik pareizais kods būtu šāds:

 

 

$regExpr = "http://";'>http://";

$look = preg_match("/".$regExpr."/", $_POST["fname"]);

if($look == false) {

 

$link_URL = $_POST["fname"];

}

else {

$link_URL = "http://" . $_POST["fname"];

}

Link to comment
Share on other sites

Kāde jēga likt "$look==false", ja ifiem gadījumā ja mainīgā vērtība ir boo, tad pie false neizpildās un pie true izpildās, vieglāk nebūtu:

 

if(!$look) {

$link_URL = $_POST["fname"];
}
else {
$link_URL = "http://" . $_POST["fname"];
} 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...