Lets say I have a variable that will always be a string.
Now take the code below:
if($myVar === "teststring")
Note $myVar will always be a string, so my questions is
Which is quicker/best, using === (Indentity) or the == (Equality)?
Fatal error:
Call to undefined function mb_substr()
after moving to my dedicated server (hypervm CP) , i got lots of errors .
it would be grateful ,if you know how to solve this problem
thanks in advance
i'm wondering about this possibility. Is it possible to make our code written in code and string compile and make it become Executable and can operate without the use of server such as Apache.
The OS environment will be Windows family.
this is a strange one.
I have a date, that is converted to mm-dd-yyyy
when posting it to mysql i have re-ordered it to yyyy-mm-dd
but yet it still will not insert
$date = date("Y-m-d", strtotime($_POST['leaving_date']) );
any advice?
Cheers
EDIT
The actual query:
mysql_query("INSERT INTO booking_info (customer_id, booking_ref, date_of_travel) VALUES (".mysql_real_escape_string($_POST['customer_id']).", ".mysql_real_escape_string($rnd).", ".mysql_real_escape_string($date).")");
If I do the following (this is the actual/direct path to the JavaScript file):
<script href="http://localhost/tpl/blue/js/functions.js" type="text/javascript"></script>
It works fine, and the JavaScript parses - as its meant too.
However I'm wanting to shorten the path to the JavaScript file (aswell as do some caching) which is why I'm rewriting all JavaScript files via .htaccess to cache.php (which handles the caching).
The .htaccess contains the following:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^js/(.+?\.js)$ cache.php?file=$1 [NC]
</IfModule>
cache.php contains the following PHP code:
<?php
if (extension_loaded('zlib')) {
ob_start('ob_gzhandler');
}
$file = basename($_GET['file']);
if (file_exists("tpl/blue/js/".$file)) {
header("Content-Type: application/javascript");
header('Cache-Control: must-revalidate');
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 3600) . ' GMT');
echo file_get_contents("tpl/blue/js/".$file);
}
?>
and I'm calling the JavaScript file like so:
<script href="http://localhost/js/functions.js" type="text/javascript"></script>
But doing that the JavaScript doesn't parse? (if I call the functions which are within functions.js later on in the page they don't work) - so theirs a problem either with cache.php or the rewrite rule? (because the file by itself works fine).
If I access the rewrited file- http://localhost/js/functions.js directly it prints the JavaScript code, as any JavaScript file would - so I'm confused as to what I'm doing wrong...
All help is appreciated! :)
I've tried to find the answer to this question but none of the answers fit.
I have two databases, one has 15.000.000 entries and I want to extract the necessary data and store it in a much smaller database with around 33.000 entries. Both databases are open at the same time. Or at least they should be.
While having the big database open and extracting the entries from it, is it possible to check whether the value already exists in the smaller database? I just need some generic way which checks that.
Ok, well, I just want to use strip_tags function on the very end of a string to get rid of any <br /> tags.
Here's what I have now, but this is no good because it strips these tags from everywhere in the string, which is not what I want. I only need them stripped out if it's at the end of the string...
$string = strip_tags($string, strtr($string, array('<br />' => ' ')));
How can I do this same thing, except only at the very end of a string??
Thanks guys!!
Hi,
I need to integrate the Web cam to the application. I need to take the user profile picture using the web cam. How can i do that. any one can help me?
Thanks in advance,
Hello all
I'm trying to find all the 6 digit numbers in a string that do not end in 00.
Something like that
/([0-9]{4})([^00])/ //i know this is wrong
so the string
asdfs dfg_123456_adsagu432100jhasj654321
will give me
results=[123456,654321] and not 432100
Thanks
Have a good day
there are plenty of frameworks for coding MVC web applications.
this time im going to code a library (think of Doctrine or Solr) with a bunch of class files. u just include a bootstrap or a class file and you are ready to use my classes.
i have never tried to code a library before and intend to code one for learning purpose so that i can use various design patterns i have learned.
are there any great frameworks for this, how i should organize the different class files, where i can put configuration files and so on?
tutorials or other information would be great too.
thanks
I have a class:
class test {
function __construct() {
print 'hello';
}
function func_one() {
print 'world';
}
}
what I would like to do is a have a class that sort of extends the test class. I say 'sort of', because the class needs to be able to run whatever function the test class is able to run, but NOT run the construct unless I ask it to. I do not want to override the construct. Anyone has any idea how to achieve this?
I have a Persons object. It has a variable name accessible by saying
$p = new Person('John');
echo $p->name;
Now I have a string.
$name = 'name';
I need to get $p->name using $p and $name. Something like
echo $p->[$name];
Hello,
I have a news site containing an archive with more than 1 million news.
I created a word definitions database with about 3000 entries, consisting of word-definition pairs.
What I want to do is adding a definition next to every occurence of these words in the news.
I cant make a static change as I can add a new keyword everyday, so i can make it realtime or cached.
The question is, a str_replace or a preg_replace would be very slow for searching 3 thousand keywords in a text and replacing them.
Are there any fast alternatives?
Introduction:
I want to loop through XML files with flexible categories structure.
Problem:
I don't know to loop through a theoretical infinte subcategories without having to make x amount of "for each" statements (See coding example in the bottom). How do I dynamically traverse the categories structure?
What I have now:
I have no problem looping through XML files with a set structure:
<catalog>
<category name="Category - level 1">
<category name="Category - level 2">
<category name="Category - level 3" />
</category>
<category name="Category - level 2">
<category name="Category - level 3" />
</category>
</category>
</catalog>
Coding example:
//$xml holds the XML file
foreach ( $xml AS $category_level1 )
{
echo $category_level1['name'];
foreach ( $category_level1->category AS $category_level2 )
{
echo $category_level2['name'];
foreach ( $category_level2->category AS $category_level3 )
{
echo $category_level3['name'];
}
}
}
I'm seeking a portable way to receive the (handy) $_SERVER['PATH_INFO'] variable.
After reading a while, it turns out PATH_INFO is originated from CGI/1.1, and my not always be present in all configuration.
What is the best (mostly security-wise) way to get that variable - apart from extracting it manually (security concern).
I decided to make a recent view box that allows users to see what links they clicked on before. Whenever they click on a posting, the posting's id gets stored in a cookie and displays it in the recent view box.
In my ad.php, I have a definerecentview function that stores the posting's id (so I can call it later when trying to get the posting's information such as title, price from the database) in a cookie. How do I create a cookie array for this?
**EXAMPLE:** user clicks on ad.php?posting_id='200'
//this is in the ad.php
function definerecentview()
{
$posting_id=$_GET['posting_id'];
//this adds 30 days to the current time
$Month = 2592000 + time();
$i=1;
if (isset($posting_id)){
//lost here
for($i=1,$i< ???,$i++){
setcookie("recentviewitem[$i]", $posting_id, $Month);
}
}
}
function displayrecentviews()
{
echo "<div class='recentviews'>";
echo "Recent Views";
if (isset($_COOKIE['recentviewitem']))
{
foreach ($_COOKIE['recentviewitem'] as $name => $value)
{
echo "$name : $value <br />\n"; //right now just shows the posting_id
}
}
echo "</div>";
}
How do I use a for loop or foreach loop to make it that whenever a user clicks on an ad, it makes an array in the cookie? So it would be like..
1. clicks on ad.php?posting_id=200 --- setcookie("recentviewitem[1]",200,$month);
2. clicks on ad.php?posting_id=201 --- setcookie("recentviewitem[2]",201,$month);
3. clicks on ad.php?posting_id=202 --- setcookie("recentviewitem[3]",202,$month);
Then in the displayrecentitem function, I just echo however many cookies were set?
I'm just totally lost in creating a for loop that sets the cookies. any help would be appreciated
Hi all
I would like to display my Query from Mysql on the table. However, my data is like this:
Array([0]=>data1, [1]=>data2, [2]=>data3,[3]=>data4,[4]=>pic1,[5]=>pic2,[6]=>pic3,[7]=>pic4);
I want to display my table as
|data1 | data2 |data3 |data4
|pic1 | pic2 |pic3 |pic4
I know how to display the data in the single ling like td or tr but not sure how to do tr and td on the same loop. Any helps? Thanks in advance!
while($query=mysql_fetch_array($dataQuery)){
//not sure what to do here.
}
I have problem about calling a static property of a class inside another class.
Class A {
public $property;
public function __construct( $prop ) {
$this->property = $prop;
}
public function returnValue(){
return static::$this->property;
}
}
Class B extends A {
public static $property_one = 'This is first property';
public static $property_two = 'This is second property';
}
$B = new B( 'property_one' );
$B->returnValue();
I expect to return This is first property But the Output is just the name a parameter input in __construct;
When I print_r( static::$this->property ); the output is just property_one
My form works in firefox but not ie. I've tried using a hidden text field (fail)... I tried using an image instead of a submit button (fail)... are there any other solutions?
How to pass a flashvar when I include the swf (to make an embedded player)
Something like this does not work..
theme-basePath.'/swf/ebook.swf?xml="test"';
header("Content-Type: application/x-shockwave-flash");
readfile($player);
?
Hello,
I'm hoping somebody knows the answer :).
Within wordpress in the users section I would like to add a new row which will data pulled in from the Register Plus plugin.
Where would I need to create a new row?
My Example:
Username Name E-mail Role **Website** Posts
Admin Admin [email protected] Administrator google.com 2
Thanks.