PHP - Not Sure What This Comparison Operators Means
hi everyone
i keep seeing the following Comparison Operators:
<>i see it used in the following context: if ($connection <> 'SSL') { $connection = 'NONSSL'; }be grateful if somone would tell me what it means, i looked online but could not find the symbol thanks Similar TutorialsHi guys I was just wondering if there is some date combination for which this type of comparisons will not work. var_dump("2010-15-1">"2010-4-01"); Provided the date is always in the YYYY-mm-dd format with optional preceding 0 . Thanks It's not PHP, but if anyone could tell me what that means and how I can edit it I would be eternally grateful. <Directory /var/www/vhosts/webaddress.co.uk/httpdocs> RMode config RUidGid (username) psacln </Directory> Can you please tell me what each of these lines of code means?
$allowedExts = array("gif", "jpeg", "jpg", "png"); $temp = explode(".", $_FILES["file"]["name"]); $extension = strtolower( end($temp) ); $length = 20; $newfilename = $_SESSION['user_id'].$_FILES["file"]["name"]; $thumbnail = $newfilename . "." . $extension; move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $thumbnail); $sql = "INSERT INTO videos ( filename ) VALUES( $thumbnail )"; mysql_query($sql); $file_location = '<a href="http://www.--.com/upload/' . $thumbnail . '">' . $thumbnail . '</a>'; $description = $description . " \n " . $newfilename; I came across usage of ^= in one the password hashing codes and am trying to find what this operator means in PHP. hello friends what does this type of array means ? $data[] = $row; Hello friends, in my database table or even php files i always find within the text something like this i love people\n i love world\n i love anything and sometimes \r and something \n\r so what does it mean is it like <br> or what ? thanks What means this syntax line: $comments = (array) $comments thanks in advance Code: [Select] <?php class Point { public $x; public $y; } // Random values 0 - 1 function random_float ($min,$max) { return ($min+lcg_value()*(abs($max-$min))); } // Fuzzy C Means Algorithm function distributeOverMatrixU($num_of_clusters, $arr,$m) { global $MatrixCentroids; $num_of_data = sizeof($arr); $MatrixPointX = $arr; // Fill the $MatrixU table with random values from 0 to 1 for($j = 0; $j < $num_of_data; $j++) { $sum = 0; for($i = 0; $i < $num_of_clusters; $i++) { $MatrixU[$j][$i] = random_float(0,1); $sum += $MatrixU[$j][$i]; } // Normalize Data for($i = 0; $i < $num_of_clusters; $i++) { $MatrixU[$j][$i] = $MatrixU[$j][$i]/$sum; } } // repeat 200 for($a = 0; $a<200; $a++) { for($i = 0; $i < $num_of_clusters; $i++) { $tempAx = 0; $tempBx = 0; $tempAy = 0; $tempBy = 0; for($j = 0 ; $j < $num_of_data; $j++) { $tempAx = $tempAx + pow($MatrixU[$j][$i],$m); $tempBx += pow($MatrixU[$j][$i],$m) * $MatrixPointX[$j]->x; $tempAy = $tempAy + pow($MatrixU[$j][$i],$m); $tempBy += pow($MatrixU[$j][$i],$m) * $MatrixPointX[$j]->y; } $MatrixCentroids[$i] = new Point(); $MatrixCentroids[$i]->x = $tempBx / $tempAx; $MatrixCentroids[$i]->y = $tempBy / $tempAy; } // Cluster Centers for($j = 0 ; $j < $num_of_data; $j++) { $tempSum = 0; for($i = 0; $i < $num_of_clusters; $i++) { // Distance between 2 points $distance1 = pow(($MatrixPointX[$j]->x - $MatrixCentroids[$i]->x),2); $distance2 = pow(($MatrixPointX[$j]->y - $MatrixCentroids[$i]->y),2); $distance = $distance1 + $distance2; $distance = sqrt($distance); $MatrixU[$j][$i] = pow(1/$distance , 2/($m-1)); $tempSum += pow(1/$distance, 2/($m-1)); } for($i = 0; $i < $num_of_clusters; $i++) { $MatrixU[$j][$i] = ($MatrixU[$j][$i]/$tempSum); } $sum = 0; for($i = 0; $i < $num_of_clusters; $i++) { $sum += $MatrixU[$j][$i]; } // Norm Data for($i = 0; $i < $num_of_clusters; $i++) { $MatrixU[$j][$i] = $MatrixU[$j][$i]/$sum; } } } //print_r($MatrixCentroids); return $MatrixU ; } // Connect to DB $my_num = $_GET["cluster_number"]; $fuzz = $_GET["fuzz"]; require('db_connection.php'); $resultx=mysql_query("SELECT * FROM xdata"); $result=mysql_query("SELECT * FROM ydata"); // &#916;&#953;&#945;&#946;&#940;&#950;&#959;&#965;&#956;&#949; &#972;&#955;&#945; &#964;&#945; &#948;&#949;&#948;&#959;&#956;&#941;&#957;&#945; while ($a_row = mysql_fetch_array($result)) { for($j = 1 ; $j < 17; $j++) { $tmp_data[$j] = $a_row[ay.$j]; } } while ($x_row = mysql_fetch_array($resultx)) { for($j = 1; $j <17; $j++) { $p = new Point(); $p->x = $x_row[ax.$j]; $p->y = $tmp_data[$j]; $arr[] = $p; } } // Execute algorithm $data_in_clusters = distributeOverMatrixU($my_num, $arr,$fuzz); $size = sizeof($arr); $result=@mysql_query('select * from cluster0 limit 1', $link); if ($result) { echo "O &#960;&#943;&#957;&#945;&#954;&#945;&#962; &#965;&#960;&#940;&#961;&#967;&#949;&#953; &#954;&#945;&#953; &#960;&#961;&#941;&#960;&#949;&#953; &#957;&#945; &#948;&#953;&#945;&#947;&#961;&#945;&#966;&#959;&#973;&#957; &#959;&#953; &#960;&#961;&#959;&#951;&#947;&#959;&#973;&#956;&#949;&#957;&#949;&#962; &#949;&#947;&#947;&#961;&#945;&#966;&#941;&#962;...<BR>"; echo "&#916;&#953;&#945;&#947;&#961;&#945;&#966;&#942;...<BR>"; for($i = 0; $i <100; $i++) { $query="DROP TABLE cluster$i"; mysql_query($query,$link); } echo "H &#948;&#953;&#945;&#947;&#961;&#945;&#966;&#942; &#941;&#947;&#953;&#957;&#949; &#956;&#949; &#949;&#960;&#953;&#964;&#965;&#967;&#943;&#945;..."; } for($j = 0; $j < $my_num; $j++) { $query_c = "CREATE TABLE cluster$j(data_points_x FLOAT NOT NULL,data_points_y FLOAT NOT NULL)"; mysql_query($query_c,$link); } for($i = 0; $i < $size ; $i++) { $max = 0; $pos = 0; for($j = 0; $j < $my_num; $j++) { $tmp_point = $data_in_clusters[$i][$j]; if($tmp_point > $max) { $max = $tmp_point; $pos = $j; } } $xxxx = $arr[$i]->x; $yyyy = $arr[$i]->y; $query="INSERT INTO cluster$pos(data_points_x,data_points_y) values('$xxxx','$yyyy')";; mysql_query($query,$link); } echo "<br>"; echo "<img src='db_scatter.php' border=0 align=center width =600 height=400>"; // &#917;&#956;&#966;&#940;&#957;&#953;&#963;&#951; &#928;&#943;&#957;&#945;&#954;&#945; &#956;&#949; &#964;&#945; &#945;&#960;&#959;&#964;&#949;&#955;&#941;&#963;&#956;&#945;&#964;&#945; echo "<table width='500' border='2'>"; echo "<TR><TD><B>Points</B><BR></TD>"; for($i = 0; $i < $my_num; $i++){ $xxx = $MatrixCentroids[$i]->x; $yyy = $MatrixCentroids[$i]->y; echo "<TD>Cluster $i Centoid:<br><b>X:$xxx Y:$yyy</b></TD>"; } echo "</tr>"; for($i = 0; $i < $size ; $i++) { $x = $arr[$i]->x; $y = $arr[$i]->y; echo "<TR>"; echo "<TD><b>x:$x</b><br><b>y:$y</b></TD>"; for($j = 0; $j < $my_num; $j++) { $tmp_point = $data_in_clusters[$i][$j]; echo "<TD> $tmp_point</TD>"; } echo "</TR>"; } echo "</TABLE>"; ?> I came across these pieces of code and have been trying to understand this operator -> Or if it is a operator. I have searched and couldn't find explanations. In trying to learn I need to know what is is used for. Is it used only with classes? $m->myMethod(); return $this->x; Hi guys! I am trying to understand why the final value of $m equals 40 in the following code Code: [Select] <?php $i = 29; $j = 11; $m = 10; $j = ($j - 4) / 2; $m += $j * 10; echo "m = ".$m."<br>"; //Equals 40 ?> Can anyone explain me please? I feel very confused right now. i'm trying to develop a deeper understanding of sessions, and I found this article on php.net regarding sessions with the following script;
<?php // Get the private context session_name('Private'); session_start(); $private_id = session_id(); $b = $_SESSION['pr_key']; session_write_close(); // Get the global context session_name('Global'); session_id('TEST'); session_start(); $a = $_SESSION['key']; session_write_close(); // Work & modify the global & private context (be ware of changing the global context!) ?> <html> <body> <h1>Test 2: Global Count is: <?=++$a?></h1> <h1>Test 2: Your Count is: <?=++$b?></h1> <h1>Private ID is <?=$private_id?></h1> <h1>Gloabl ID is <?=session_id()?></h1> <pre> <?php print_r($_SESSION); ?> </pre> </body> </html> <?php // Store it back session_name('Private'); session_id($private_id); session_start(); $_SESSION['pr_key'] = $b; session_write_close(); session_name('Global'); session_id('TEST'); session_start(); $_SESSION['key']=$a; session_write_close(); ?> [EDIT BY danbrown AT php DOT net: Contains a bugfix provided by (lveillette AT silexmultimedia DOT com) on 19-NOV-09.]I do not understand line 21 and 22. <h1>Test 2: Global Count is:<?=++$a?></h1>If I change this to; <h1>Test 2: Global Count is:<?php echo =++$a; ?></h1> or <h1>Test 2: Global Count is:<?php =++$a ?></h1>I would get a parse error, unexpected "=" in line 21. Can anyone explain why this is? * Why is it being echoed * Why can I not use echo in this case * Why does the code not start with <?php ? * What does line 21 even mean? =++$a? Thanks in advance guys! Edited by empec, 13 July 2014 - 11:30 AM. I'm trying to get an equation from a user that types it in the url, ex) 1+2+3. I can get the 1,2,3 fine, but the + operator is no longer in the string. Same with the * and / operators. Is there a way to keep them as a string using $_GET?
Hi every one, I just want to know what is the use of '<<' and '>>' operators in php I have a query that is very messy. I have tried using () to seperate everything and when I do it just all goes wrong. here is the query SELECT posts.*, users.*, countries.countryID, countries.country FROM posts INNER JOIN users ON users.userID = posts.postUserID INNER JOIN countries ON countries.countryID = users.userCountry WHERE posts.cityID = '".$row_rs_city['cityID']."' AND posts.type = 'sightseeing' OR posts.cityID = '".$row_rs_city['cityID']."' AND posts.type = 'Inner city sightseeing' OR posts.cityID = '".$row_rs_city['cityID']."' AND posts.type = 'Outer city sightseeing' ORDER BY posts.postID DESC Is there a way of re-writing this so that it has brackets seperating everything and it will still work. It works for the minute but re- writing posts.cityID = '".$row_rs_city['cityID']."' inbetween every OR just seems wrong. Thanks for your help guys While going through an instructional book, I ran across some code that I didn't immediately understand. I've stripped it down to the relevant bits: function example($object_a, $object_b) { $compare = $object_a->id == $object_b->id; return another_function('argument 1') && $compare || another_function('argument 2'); } My first confusion was this line: $compare = $object_a->id == $object_b->id; Does this set $compare to TRUE if the ids match and FALSE if they do not? And the second confusion: return another_function('argument 1') && $compare || another_function('argument 2'); What is returned if the ids match? What is returned if they are different? When I try testing this out on my machine, it returns both functions whether or not the ids match, but I know that's not what's supposed to happen. Can anyone break this down for me? Thanks. In php is there a way to shortcut logical operators... example: Code: [Select] if ($row['CustomerSaas'] == 'Yes' && ($row['CustomerSaasPaidStatus'] == 'Trial' || $row['CustomerSaasPaidStatus'] == 'Trial Ended')) { to Code: [Select] if ($row['CustomerSaas'] == 'Yes' && ($row['CustomerSaasPaidStatus'] == 'Trial' || 'Trial Ended')) { Hello. Im having trouble using a Tempory Operator in a list. maybe someone might know a way around it. so the list below has 3 Tempory Operators. the first 1 looks for pages with links that are internal links the first 2 looks for pages with links that are external links the first 3 looks for pages with links that have no links if the link is a "nonTitle" it will be a normal list item if the link is a "title" it will be a header for a sub list (class="subexpandable") the problem is that every time it gets to the '; at the end of each Tempory Operators it breaks THIS IS NOT WORKING Code: [Select] <ul> //FIND INTERNAL LINKS echo $type == "internal" && $list == "nonTitle" ? '<li><a href="index.php">'.$title.'</a></li>' : '<li><a href="index.php" class="subexpandable">'.$title.'</a>'; //FIND EXTERNAL LINKS echo $type == "external" && $list == "nonTitle" ? '<li><a href="http://www.url.com">'.$title.'</a></li>' : '<li><a href="http://www.url.com" class="subexpandable">'.$title.'</a>'; //FIND NON LINKS echo $type == "non" && $list == "nonTitle" ? '<li><a>'.$title.'</a></li>' : '<li><a class="subexpandable">'.$title.'</a>'; //GET SUB LINKS echo' <ul class="subcategoryitems" style="margin-left: 15px"> <li><a href="">sub link</a></li> </ul> </li> </ul>'; If i put the sub level inside of each type it works but then i keep having to use the same code over. THIS IS WORKING Code: [Select] <ul> //FIND INTERNAL LINKS echo $type == "internal" && $list == "nonTitle" ? '<li><a href="index.php">'.$title.'</a></li>' : '<li><a href="index.php" class="subexpandable">'.$title.'</a> <ul class="subcategoryitems" style="margin-left: 15px"> <li><a href="">sub link</a></li> </ul> </li>'; //FIND EXTERNAL LINKS echo $type == "external" && $list == "nonTitle" ? '<li><a href="http://www.url.com">'.$title.'</a></li>' : '<li><a href="http://www.url.com" class="subexpandable">'.$title.'</a> <ul class="subcategoryitems" style="margin-left: 15px"> <li><a href="">sub link</a></li> </ul> </li>'; //FIND NON LINKS echo $type == "non" && $list == "nonTitle" ? '<li><a>'.$title.'</a></li>' : '<li><a class="subexpandable">'.$title.'</a> <ul class="subcategoryitems" style="margin-left: 15px"> <li><a href="">sub link</a></li> </ul> </li>'; </ul>'; so is there a way to do the first example without having to do the second example thanks ricky Hello I'm trying to use PHP "for loops" to build a table of 10 rows with 5 columns and I'm sure there's a better way to do this, but the result is the page won't fully load and continually spins its wheel. Here's the code: Code: [Select] $states = array(1 => 'AK','AL','AR','AZ','CA','CO','CT','DC','DE','FL','GA','HI','IA','ID','IL','IN','KS','KY','LA','MA','MD','ME','MI','MN','MO','MS','MT','NC','ND','NE','NH','NJ','NM','NV','NY','OH','OK','OR','OZ','PA','PR','RI','SC','SD','TN','TX','UT','VA','VT','WA','WI' ); <table id="stateCheck"> <?php for ($i = 1; $i <= 10; $i++) { echo '<tr>'; for ($j = 5*$i; $j <= $j+4; $j++) { echo '<td> <input type="checkbox" name="state" value="'.$states[$j].'" /> '.$states[$j].' </td>'; } echo '</tr>'; } ?> <tr> <td> <input type="checkbox" name="state" value="WV" /> WV </td> <td> <input type="checkbox" name="state" value="WY" /> WY </td> </tr> </table> Is it breaking because I'm using arithmetic operators to define the nested for loop? Many thanks I was looking at the manual:
http://php.net/manua....precedence.php
And I notice that the parenthesis () operator and print operator are missing from the list. Why so? I would like to know where these operators fall in the precedence and associativity chart.
Can someone help me understand parentheses structure? Why here does the second empty() have no parentheses before it and an extra parentheses at the end? if (empty($subject) && empty($text)) { .... And here, why is there an extra parentheses at the end? if (empty($subject) && (!empty($text))) { ... And here, why double parentheses in the 1st empty() and none before the 2nd empty() ? if ((!empty($subject)) && empty($text)) { ... Thank You! michael |