I tried this but only got a syntax error:
<?php
$a = true;
$str = <<< EOF
{$a ? 1 : 2}
EOF;
echo $str;
Is it possible to use such kind of conditional statement inside heredoc?
There is no limitation on the depth.
How to get the structed branch or even entire tree?
The definition is from here:
http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
I am currently building a site and all the books I have read on PHP so far are just on functionality and not much on security. Is there a book that deals specifically with making your code/site secure? I don't want to go public and the next day have all my code changed or my database erased by SQL injection.
thanks
Hi,
I have a PHP script that runs database queries. Now, if a query fails, should I trigger an error or throw an exception? I noticed that if I do the latter, the script execution will stop after facing the exception.
My code is as follows:
if (!$this->connection[0]->query($this->query))
throw new Exception($this->connection[0]->error);
What are the pros and cons of using exceptions for this kind of cases (failed queries)?
I have a step 1 page, and a step 2 page. I want to take the information from step 1 page, then step 2 page, and save as session information (which i have already done). Once this information is all gathered i then want to be able to submit it to another php page using HTTP POST.
Hello Friends!
I want to develop a shopping cart in php. I also want to integreate online payment facility using paypal.
Which allows payment thrugh credit card and decbit card.
So Please tell me how to integreate paypal in my own shopping cart to achive secure transaction?
Thank You!
hi,
I've 2 sets of thumbnails and in each set I'm displaying them one nearby each other in 4 columns using float:left.
I would like to "merge" the 2 sets (but I cannot change the html code) because I want the thumbnails of the second set floating right after the last thumbnail of the first set.
In other terms, if in the last row there are only 2 thumbnails and the last 2 columns are empty, the thumbnails of the second set should fill the empty columns of the last row of the first set.
This is the code...
<div class="field field-type-filefield field-field-image">
<div class="field-items">
<div class="field-item odd">
<a rel="lightbox[field_image][First image<br /><br /><a href="/lancelmaat/content/stalkshow" id="node_link_text" class="active">View Image Details</a>]" href="http://localhost/lancelmaat/sites/default/files/files/projects/Stalkshow/images/LPrisPetjong.jpeg" class="lightbox-processed"><img width="89" height="89" title="" alt="First image" src="http://localhost/lancelmaat/sites/default/files/imagecache/galleryImage/files/projects/Stalkshow/images/LPrisPetjong.jpeg"></a> </div>
<div class="field-item even">
<a rel="lightbox[field_image][Second image<br /><br /><a href="/lancelmaat/content/stalkshow" id="node_link_text" class="active">View Image Details</a>]" href="http://localhost/lancelmaat/sites/default/files/files/projects/Stalkshow/images/SeoulLEDScreen2a.jpeg" class="lightbox-processed"><img width="89" height="89" title="" alt="Second image" src="http://localhost/lancelmaat/sites/default/files/imagecache/galleryImage/files/projects/Stalkshow/images/SeoulLEDScreen2a.jpeg"></a> </div>
<div class="field-item odd">
<a rel="lightbox[field_image][Third image<br /><br /><a href="/lancelmaat/content/stalkshow" id="node_link_text" class="active">View Image Details</a>]" href="http://localhost/lancelmaat/sites/default/files/files/projects/Stalkshow/images/SeoulSKT6.jpeg" class="lightbox-processed"><img width="89" height="89" title="" alt="Third image" src="http://localhost/lancelmaat/sites/default/files/imagecache/galleryImage/files/projects/Stalkshow/images/SeoulSKT6.jpeg"></a> </div>
</div>
<!-- second set -->
<div class="field field-type-filefield field-field-video">
<div class="field-items">
<div class="field-item odd">
<a rel="lightbox[field_video][Video Number 1<br /><br /><a href="/lancelmaat/content/stalkshow" id="node_link_text" class="active">View Image Details</a>]" href="http://localhost/lancelmaat/sites/default/files/files/projects/Stalkshow/videos/StalkSeoul8d1Mbps.flv" class="lightbox-processed"><img title="" alt="Video Number 1" src="http://localhost/lancelmaat/sites/default/files/imagecache/galleryVideo/files/projects/Stalkshow/videos/StalkSeoul8d1Mbps.flv"></a> </div>
<div class="field-item even">
<a rel="lightbox[field_video][Video Number 2<br /><br /><a href="/lancelmaat/content/stalkshow" id="node_link_text" class="active">View Image Details</a>]" href="http://localhost/lancelmaat/sites/default/files/files/projects/Stalkshow/videos/stalkshowdvd21Mbps.flv" class="lightbox-processed"><img title="" alt="Video Number 2" src="http://localhost/lancelmaat/sites/default/files/imagecache/galleryVideo/files/projects/Stalkshow/videos/stalkshowdvd21Mbps.flv"></a> </div>
<div class="field-item odd">
<a rel="lightbox[field_video][Video Number 3<br /><br /><a href="/lancelmaat/content/stalkshow" id="node_link_text" class="active">View Image Details</a>]" href="http://localhost/lancelmaat/sites/default/files/files/projects/Stalkshow/videos/StalkShowMoscow1Mbps.flv" class="lightbox-processed"><img title="" alt="Video Number 3" src="http://localhost/lancelmaat/sites/default/files/imagecache/galleryVideo/files/projects/Stalkshow/videos/StalkShowMoscow1Mbps.flv"></a> </div>
</div>
</div>
How can I merge these divs in order to use float:left property on their children ?
thanks
I have a PHP script on a webserver.
This file is invoked via the shell by another program but it could still be run by the webserver in response to an HTTP request.
How can the script determine the way it was invoked?
I'm using WordPress as a CMS, and I want to extend one of its classes without having to inherit from another class; i.e. I simply want to "add" more methods to that class:
class A {
function do_a() {
echo 'a';
}
}
then:
function insert_this_function_into_class_A() {
echo 'b';
}
(some way of inserting the latter into A class)
and:
A::insert_this_function_into_class_A(); # b
Is this even possible in tenacious PHP?
I am new to coding and would just like to know a bit more about frameworks. How does a framework help you code and what exactly is it? Such as Zend for php.
Money, Staff, Skill and preference to open source or commercial is neutral. Lets take the best of the best programmers (for arguments sake) and think about this:
What will perform better overall:
PHP & MySQL
or
ASP.Net & Microsoft SQL
(I don't want biased answers, just
looking for Performance, and Speed).
I need to return a JSON encoded response to a flash http get request.
In ASP.NET, I do this with a ASHX handler.
What's the PHP equivalent ?
I mean in order that I only get JSON back, and not the <html> etc.
In some languages (ColdFusion comes to mind), you can run a query on the result set from a previous query. Is it possible to do something like that in php (with MySQL as the database)?
I sort of want to do:
$rs1 = do_query( "SELECT * FROM animals WHERE type = 'fish'" );
$rs2 = do_query( "SELECT * FROM rs1 WHERE name = 'trout'" );
Dear all,
I want to create multiple thumbnails using GD library in php, and I already have a script to do this, the question is what is better for me .. is it better to create thumbnail on the fly? or create a physical file on my server each time I want a thumb?? and Why?
Please, consider time consuming and storage capacity and other disadvantages for both
Hi,
I have 5 textfields for user input in a form namely:
username1, username2, username3, username4 and username5
I would like to know how should I write my php code such that I will be able to check if there is any duplicates between the 5 textfields during POST?
I can only think of comparing (username1 !== username2) and so on, but I think there should be simpler way to do it right? How should I be able to do it?
Thank you very much.
I have a html form where visitors can fill and send me some information, as an e-mail. It sends like this:
$body = print_r($_POST, true);
mail ($to, $subject, $body, $headers);
When they write abc'def I get abc\'def
What is this additional \? How I can prevent it?
I know that:
preg_replace('<br\s*\/?>', '', $string);
will remove all br tags from $string...
How can we remove all <br><br/><br /> tags only if they are in the very beginning of $string? ($string in my case is html code with various tags...)
I am thinking about setting the
php.ini, my.cnf and httpd.conf default charsets=UTF-8
The website is in swedish lang only.
I have some folders with special chars in them, also some files.
Is there any harm by doing this?
Is it cross-browser safe?
Thanks
Hi
I need to know how to get the first n words from text stored in my DB in PHP?
for example if there is some text in my DB like this one :
"word1 word2 word3 word4 text one test four five"
How I can get the first 4 or five words from this text?
Thnks in Advance.
hi, i want only the first word of a variable.. example input:
<?php $myvalue = Test me more; ?>
the output should only "Test", the first word of the input.. how can i do this?
I have a directory that will be getting updated frequently, I want to display the last four images files uploaded, which match a certain pattern, on my php page.
Is this possible without having to perform a sort on every single image within the directory?
Many thanks!
How to fetch the first two rows from Mysql DB using Mysql PHP function? Is there any function which can give me first 2 or 3 rows from the select query we fired?