php

How can I open a new browser tab in Eclipse PDT?

蓝咒 提交于 2021-02-19 08:42:00
问题 When I run a PHP script in Eclipse environment, I can select different browsers to render my page and can get different results. But the results are still all shown in the browser output window in eclipse itself. How can I prompt eclipse to actually open a new tab in the browser itself with the php page. I know it can be done by "external tools", just dont know how exactly to configure it. 回答1: From the main menu -> Windows -> Preferences -> General -> Browser -> select the external browser

Export large CSV file using laravel

我怕爱的太早我们不能终老 提交于 2021-02-19 08:37:27
问题 I have to export 600k database rows with a belongsTo relationship between two tables to a csv file using a queued job in laravel 5.2, it works fine when I do not include the information from the second table, but it reaches memory limit or timeout I guess (there is no error on the output, the job just stops and the file blocks at ~8MB) when I include the second table. Here is my handle function from my job : public function handle() { $request = $this->request; $ts = Carbon::now()->timestamp;

Show A Base64 Image On PHP Page Using Image header() & readfile()

六眼飞鱼酱① 提交于 2021-02-19 08:27:26
问题 I am working on a script where after some operation of PHP functions, I generate a base64 image data in $base64Image variable. Now I want to show that base64 image data as a full image on the web browser same as an image.jpeg . For this purpose, I wrote some codes as shown below... screenshot.php <?php /*------------------------ // Basic PHP Operations // ------------------------*/ // Get URL Parameters $key1 = $_GET["key1"]; $key2 = $_GET["key2"]; // Some PHP Operations......................

String to multidimensional/recursive array in PHP

女生的网名这么多〃 提交于 2021-02-19 08:25:06
问题 I have a problem with creating a recursive array with PHP. I need to format this string to a multidimensional array with the dot-separated elements indicating multiple levels of array keys. $str = "code.engine,max_int.4,user.pre.3,user.data.4"; The output for this example would be: $str = array( "code" => "engine", "max_int" => 4, "user" => array( "pre" => 3, "data" => 4 ) ); I will start with an explode function, but I don't know how to sort it from there, or how to finish the foreach. 回答1:

Good Way to Email Exceptions

江枫思渺然 提交于 2021-02-19 08:23:08
问题 I am running a site on Ubuntu with Apache and using PHP and Zend Framework. I would like exception information emailed to the devs and am wondering about a good way to do this. I don't want to email every single exception right away because if something major happens, our inboxes will get flooded. Instead, I am looking for a way that the exceptions and errors from the past hour can be emailed all at once (up to a certain size limit). I am thinking about writing a cron script to parse Apache's

Format date within an echo

…衆ロ難τιáo~ 提交于 2021-02-19 08:21:33
问题 I'm trying to format a MySQL formatted date (YYYY-MM-DD) and wish to display the month and year, "September 2012" for example. My code: <?php echo htmlspecialchars($row["date"], ENT_QUOTES, "UTF-8"); ?> Does anyone know how I can accomplish this? 回答1: You can use DateTime to format your date how you'd like: $date = DateTime::createFromFormat('Y-m-d', $row["date"]); echo htmlspecialchars($date->format('F Y'), ENT_QUOTES, "UTF-8"); So with a date like this: $row['date'] = '2012-09-25'; This

Creating PNG thumbnail using PHP

孤人 提交于 2021-02-19 08:20:28
问题 I'm trying to create a thumbnail image it returned an error, that imagecopyresized() expects 2 parameter to be resource, but it can create the image but the output is only a small black image. here is my code $image = "asd.PNG"; $image_size = getimagesize($image); $image_width = $image_size[0]; $image_height = $image_size[1]; $new_size = ($image_width + $image_height)/($image_width*($image_height/45)); $new_width = $image_width * $new_size; $new_height = $image_height * $new_size; $new_image

Getting all product ids of woocommerce categories

痴心易碎 提交于 2021-02-19 08:16:13
问题 I am trying to get all product ids using product_cat here is my code function get_products_from_category_by_ID( $category ) { $products_IDs = new WP_Query( array( 'post_type' => 'product', 'post_status' => 'publish', 'fields' => 'ids', 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'product_cat', 'field' => 'term_id', 'terms' => $category, ) ), ) ); return $products_IDs; } var_dump( get_products_from_category_by_ID( 196 ) ); But getting WP_Query objects instead of ids of

Hiding products without thumbnail in WooCommerce shop page

不问归期 提交于 2021-02-19 08:13:07
问题 I use importer which imports thousands of products to the shop. Although I must insert picture and description for the product before I want to sell the item. I would like to hide product from the store at all IF there is no thumbnail image assigned. This way new products appear to the shop only after I have set the thumbnail image. I tried this in header.php, but did not work: <?php if($_product->getImage() && $_product->getImage() != 'no_selection'){ ?> <style> /* Css to hide Featured image

Creating FTP user accounts using FTP on server

瘦欲@ 提交于 2021-02-19 08:12:30
问题 Thanks for your wonderful help with my code last week. I have a VPS running and for my server/website, for each new account I would like to give each user a 50 meg upload space and FTP credentials. The username and password for the FTP would be unique to each user and the folder would be easily accessible only by them and myself. I have written a script that can connect to the FTP for my VPS but where would I need to go from here? Specifically for creating ftp login details for a user that