AFUP PHPTour 2018 Baromètre Planète PHP
planete-php.fr Articles Blogs Infos RSS Feed Atom Feed Twitter

Articles

file exist php

Pascal Cescato (expert-php) 24/04/18

in response to seejohnrun’s version to check if a url exists. even if the file doesn’t exist you’re still going to get headers. you can still use get_headers if you don’t have the option of using curl.. $file = ‘ do/somefile.jpg’; $file_headers = get_headers($file); if($file_headers[] == ‘ not 
definition and usage. the file_exists() function checks whether or not a file or directory exists. this function returns true if the file or directory exists, otherwise it returns false.
file_exists checks whether a file exist in the specified path or not. syntax: file_exists ( string $filename ). returns true if the file or directory specified by filename exists; false otherwise. $filename = base_dir. »images/a/test.jpg »; if (file_exists($filename)){ echo « file exist. »; }else{ echo « file does not exist.

file exist php

Vu sur i.ytimg.com

file exist php

Vu sur i.stack.imgur.com

file exist php

Vu sur i.ytimg.com

you need the filename in quotation marks at least (as string): if (file_exists(‘ mydo/images/’.$filename)) { … } also, make sure $filename is properly validated. and then, it will only work when allow_url_fopen is activated in your php config.
just try to use like this: $filename = dirname(__file__) . « / $mymedia catalog/category/ $myimage.png »; $filename = str_replace( » « , «  », $filename); if (file_exists($filename)) { echo « the file $filename exists »; } else { echo « the file $filename does not exist« ; }.
if(file_exists(‘file.php’)) include ‘file.php’;. that should do what you want.

html>

Voir la suite

php display_errors

Pascal Cescato (expert-php) 24/04/18

php display_errors

Vu sur i.ytimg.com

this always works for me: ini_set(‘display_errors‘, ); ini_set(‘display_startup_errors’, ); error_reporting(e_all);. however, this doesn’t make php to show parse errors the only way to show those errors is to modify your php.ini with this line: display_errors = on.

php display_errors

Vu sur carme.cs.trinity.edu

voyez aussi la directive display_errors. en php . et suivants, la valeur par défaut est is e_all & ~ e_notice & ~ e_strict & ~ e_deprecated . cette configuration n’affiche pas les alertes de niveau e_notice , e_strict et e_deprecated . vous devriez vouloir les afficher pendant vos développements.

php display_errors

Vu sur ruslany.net

if you just see a blank page instead of an error reporting and you have no server access so you can’t edit php configuration files like php.ini try this: create a new file in which you include the faulty script: <?php error_reporting(e_all); ini_set("display_errors« , ); include(« file_with_errors.php »); ?> execute this file instead of 

php display_errors

Vu sur alanstorm.com

some server are configured to omit php errors on pages using the directive display_errors=off; in most cases, the server will output a internal server error instead of php error because of it. to prevent this default you must set this directive directly in the php.ini file and the server will show you the php error properly.

php display_errors

Vu sur ruslany.net

so in place of e_all consider using a larger value to cover all bit fields from now and well into the future, a numeric value like (includes all errors, not just e_all). display_errors string. this determines whether errors should be printed to the screen as part of the output or if they should be hidden from the user.

php display_errors

Vu sur carme.cs.trinity.edu

i have used the following method to bypass this limitation: the syntax error is inside the file « syntax.

Voir la suite

php cast string to int

Pascal Cescato (expert-php) 24/04/18

for more information, see the section on floating point numbers in the php manual ( php.net/manual/language.types.double.php) also note that if you try to convert a string to an integer, the result is often . however, if the leftmost character of a string looks like a valid numeric value, then php will keep reading the 
you don’t typically need to do this, since php will coerce the type for you in most circumstances. for situations where you do want to explicitly convert the type, cast it: $num = « . »; $int = (int)$num; $float = (float)$num;.
you can remove the spaces before casting to int : (int)str_replace(‘ ‘,  », $b);. also, if you want to strip other commonly used digit delimiters (such as , ), you can give the function an array (beware though in some countries, like mine for example, the comma is used for fraction notation):

php cast string to int

Vu sur i.stack.imgur.com

php cast string to int

Vu sur i.stack.imgur.com

php cast string to int

Vu sur wp2x.com

. <?php. $toto = "" ;. if ( is_int ( $toto )) echo ' : toto est int
‘ ;. else echo ‘ : toto n\’est pas int
‘ ; pas int. $toto = (int) $toto ;. if ( is_int ( $toto )) echo ‘ : toto est int
‘ ; int. else echo ‘ : toto n\’est pas int
‘ ;. $toto = «  » ;. $toto = intval ( $toto );. if ( is_int ( $toto )) echo ‘ : toto est int 
here is a type conversion from string to int, the same way, with php & mysql. basically, you can change the type of your string by adding . php. $myvar = «  »; var_dump($myvar); string  » (length=) $myvar= $myvar ; or $myvar= var_dump($myvar); int . mysql. select from 
php:converting data types. string to number. number to string · chars to string · string to chars · int to float · float to int. the language will automatically convert the string to an integer as required. you can use the function intval. the value «  » is a string, you need to treat it as a number to add , 

php cast string to int

Vu sur i.stack.imgur.com

html>

Voir la suite

php json_encode object

Pascal Cescato (expert-php) 24/04/18

a note of caution: if you are wondering why json_encode() encodes your php array as a json object instead of a json array, you might want to double check your array keys because json_encode() assumes that you array is an object if your keys are not sequential. e.g.: <?php $myarray = array('isa', 'dalawa', 'tatlo');

php json_encode object

Vu sur akawebdesign.com

php json_encode object

Vu sur i.stack.imgur.com

mai in redbeanphp . there is a massexport function which turns an entire collection of beans into arrays. this works with the json encoder.. json_encode( r::exportall( $beans ) );.
$_files[‘filedata’][‘name’]; $photo>position = $max_position ; $photo>statut = ; echo json_encode($photo); me renvoie. {} je suis en localhost actuellement, qui est bien en utf. j’ai vérifié mon fichier php, qui était en ansi, et que je viens de convertir en utf (without bom). mais toujours pareil 

php json_encode object

Vu sur i.stack.imgur.com

php file explained: convert the request into an object, using the php function json_decode(). access the database, and fill an array with the requested data. add the array to an object, and return the object as json using the json_encode() function.
update: the first comment by michd is the real protip. his hint made this whole thing useless. json_encode($array) is a fine way to convert a php array or object into a string for saving it into a database. $myarray = array(‘firstvalue’, ‘secondvalue’); $myarrayjsonencoded = json_encode($myarray); results to 

php json_encode object

Vu sur i.stack.imgur.com

php json_encode object

Vu sur packtpub.com

with json_encode, you can translate anything that is utf encoded (except resources) from php into a json string. as a rule of thumb, everything except pure arrays (in php this means arrays with an ordered, numerical index) is converted into an object with keys and values. the method call is easy and 
déc.

Voir la suite

php array_push array

Pascal Cescato (expert-php) 23/04/18

array_push() considère array comme une pile, et empile les variables var , à la fin de array . la longueur du tableau array augmente d’autant. cela a le même effet que : <?php $array[] = $var; ?> répété pour chaque valeur. note: si vous utilisez la fonction array_push() pour ajouter un élément à un tableau, il est mieux de 
array_merge is the elegant way: $a = array(‘a’, ‘b’); $b = array(‘c’, ‘d’); $merge = array_merge($a, $b); $merge is now equals to array(‘a’,’b’,’c’,’d’);. doing something like: $merge = $a $b; $merge now equals array(‘a’,’b’). will not work, because the operator does not actually merge them. if they $a 
definition and usage. the array_push() function inserts one or more elements to the end of an array. tip: you can add one value, or as many as you like. note: even if your array has string keys, your added elements will always have numeric keys (see example below).

php array_push array

Vu sur ketnoinhau.files.wordpress.com

php array_push array

Vu sur w3resource.com

php array_push array

Vu sur java2s.com

<?php $arr=array(,,,); array_push($arr,); foreach($arr as $element) echo « $element, « ; , , , , array_push($arr,,,); foreach($arr as $element) echo « $element, « ; , , , , , , , ?> if you want to append elements to an associative array, just define the key and values. <?
hello there, i am hoping that someone can help me. i am struggling a little bit with php arrays. i am relatively new to php programming. i am in the process of writing a web application for a college thesis. the system is an online multiple choice system. i have a web form that selects questions and answers 
the array_push() function is used to add one or more elements onto the end of an array. the length of array increases by the number of variables pushed.

html>

Voir la suite

php session id

Pascal Cescato (expert-php) 23/04/18

si id est fourni, il remplacera l’identifiant courant de session. session_id() doit alors être appelé avant session_start(). suivant le gestionnaire de sessions que vous utilisez, tous les caractères ne seront pas acceptés dans cette valeur. par exemple, le gestionnaire de sessions par défaut, basé sur les fichiers, n’accepte que 
before getting a session id you need to start a session and that is done by using: session_start() function. now that you have started a session you can get a session id by using: session_id(). a small piece of code for setting, displaying and destroying session in php <?php session_start(); 
déc. this article will show you how to attack a session mechanism. use browsers weakness. php generally has two options for the transmission of session ids. both of them are very interesting from our point of view. the first is to transfer the session identifier in the address, so the session id is then available to 

php session id

Vu sur synet.sk

php session id

Vu sur brainbell.com

php session id

Vu sur image.slidesharecdn.com

these state files need not be explicitly created and managed. the following are the steps for saving and retrieving values of session variables. step : near the beginning of the program a directive to start the session must be given. php checks if there is already a session id coming from a cookie, posted data, or a query 
what is a php session? when you work with an application, you open it, do some changes, and then you close it. this is much like a session. the computer knows who you are. it knows when you start the application and when you end. but on the internet there is one problem: the web server does not know who you are or 
session_id. (php , php , php ) the constant sid can also be used to retrieve the current name and session id as a string suitable for adding to urls. see also session handling. parameters. id. if id is specified, it will replace the current session id. session_id() needs to be called before session_start() for that purpose.

Voir la suite

php readline

Pascal Cescato (expert-php) 23/04/18

php readline

Vu sur i.stack.imgur.com

if your cli script accepts input from stdin and you also want it to prompt for a password (e.g. as mysql client does), then readline() won’t work for you. what you need to do is read from the terminal device as shown below. function readline_terminal($prompt =  ») { $prompt && print $prompt; $terminal_device = ‘/dev/tty’;

php readline

Vu sur i37.tinypic.com

i wanted to get console input in a php script running on windows, so i made a little hack, which is so simple, it is clearly public do. what i did was write a c program to get a line, then output it. then all that is needed is to exec() that program and capture the output readline() for windows. the c source is as follows:

php readline

Vu sur schlueters.de

list at lunch dot za dot net ¶. years ago. when readline is enabled, php switches the terminal mode to accept linebuffered input. this means that the proper way to use the cli when you pipe to an interactive command is to explicitly specify that php is not using the terminal for input: php somescript.php < /dev/null | less.

php readline

Vu sur psysh.org

you can use the fgets() function to read the file line by line: $handle = fopen(« inputfile.txt », « r »); if ($handle) { while (($line = fgets($handle)) !== false) { process the line read. } fclose($handle); } else { error opening the file. }.

php readline

Vu sur image.slidesharecdn.com

github is where people build software. more than million people use github to discover, fork, and contribute to over million projects.

php readline

Vu sur i.stack.imgur.com

md.sum jan : phpreadline…hint dec : phpreadline…tar.xz dec : phpreadline…hint jan : phpreadline…tar.xz jan : phpreadline…hint sep : phpreadline…tar.xz 

html>

Voir la suite

is null

Pascal Cescato (expert-php) 23/04/18

what is a null value? a field with a null value is a field with no value. if a field in a table is optional, it is possible to insert a new record or update a record without adding a value to this field. then, the field will be saved with a null value. note: it is very important to understand that a null value is different from a zero 
note. the isnull() function returns the alt_value, if the expression is a null; the isnull() function returns the expression, if the expression is not null. technical details. works in: sql server , sql server , sql server r, sql server , sql server . more examples. example. return an 
isnull ( check_expression , replacement_value ). arguments. check_expression. is the expression to be checked for null. check_expression can be of any type. replacement_value. is the expression to be returned if check_expression is null. replacement_value must be of a type that is implicitly 

is null

Vu sur codeproject.com

is null

Vu sur javatpoint.com

is null

Vu sur i.ytimg.com

dans le langage sql, l’opérateur is permet de filtrer les résultats qui contiennent la valeur null. cet opérateur est indispensable car la valeur null est une valeur inconnue et ne peut par conséquent pas être filtrée par les opérateurs de comparaison (cf. égal, inférieur, supérieur ou différent).
mysql : la fonction isnull() prend un seul paramètre et permet de vérifier si une données est nulle; sql server : la fonction isnull() prend paramètres et sert à afficher la valeur du ème paramètre si le premier paramètre est null. cette même fonctionnalité peut être effectuée par d’autres systèmes de gestion de base 
null is a special value that signifies ‘no value’. comparing a column to null using the = operator is undefined. instead, use where is null or where is not null. the definitive guide for data professionals. order today! see min video 

is null

Vu sur javatpoint.com

is null

Vu sur i.

Voir la suite

readdir

Pascal Cescato (expert-php) 22/04/18

readdir

Vu sur i.ytimg.com

looking through the examples, i can’t see any that do a simple check on the value of the directory resource that opendir returns and is subsequently used by readdir. if opendir returns false, and you simply pass this to the readdir call in the while loop, you will get an infinite loop. a simple test helps prevent this: <?php

readdir

Vu sur hackintoshrao.files.wordpress.com

la fonction readdir() renvoie un pointeur sur une structure dirent représentant l’entrée suivante du flux répertoire pointé par dir. elle renvoie null à la fin du répertoire, ou en cas d’erreur. sous linux, la structure dirent est définie de la façon suivante : struct dirent { ino_t d_ino; numéro d’inœud off_t 

readdir

Vu sur raw.githubusercontent.com

the readdir() function returns a pointer to a dirent structure representing the next directory entry in the directory stream pointed to by dirp.

readdir

Vu sur os.mbed.com

the readdir() function returns a pointer to a dirent structure representing the next directory entry in the directory stream pointed to by dirp. it returns null on reaching the end of the directory stream or if an error occurred. in the glibc implementation, the dirent structure is defined as follows: struct dirent { ino_t d_ino; inode 

readdir

Vu sur sourcecodebrowser.com

the readdir() function returns a pointer to a structure representing the directory entry at the current position in the directory stream specified by the argument dirp, and positions the directory stream at the next entry. it returns a null pointer upon reaching the end of the directory stream. the structure dirent defined by the 

readdir

Vu sur i.ytimg.com

the type dir, which is defined in the header, represents a directory stream, which is an ordered sequence of all the directory entries in a particular directory.

Voir la suite

syntaxe php

Pascal Cescato (expert-php) 22/04/18

séparateur d’instruction; affichages; versions de php; variables; opérateurs. . opérateur binaire d’affectation; . opérateurs binaires de calcul. .. dates. . opérateurs de comparaisons; . concaténation; . troncature; . opérateurs unaires; . opérateurs d’incrémentations 

syntaxe php

Vu sur pierre-giraud.com

syntaxe php

Vu sur image.slidesharecdn.com

the xml declaration does not need to be handled specially. you should output it via an echo statement, in case your code is ever used on a server that is (poorly) configured to use short open tags. but there’s no need to treat the ?> at the end of the string specially. that’s because it’s in a string. the only thing php ever 
syntaxe ¶. vous pouvez définir une constante en utilisant la fonction define() ou en utilisant le motclé const en dehors d’une définition de classe à partir de php … tant que define() permet de définir une constante pour une expression arbitraire, le motclé const a des restrictions comme indiqué dans le paragraphe 

syntaxe php

Vu sur pierre-giraud.com

class ¶. une définition de classe basique commence par le motclé class, suivi du nom de la classe. suit une paire d’accolades contenant la définition des propriétés et des méthodes appartenant à la classe. le nom de la classe peut être quelconque à condition que ce ne soit pas un mot réservé en php. un nom de classe 
aller à iiil. syntaxe syntaxe : sélectionnez. <?php function ( ) { return ; (optionnel) }. une fonction permet de réutiliser facilement du code php. par exemple si vous devez effectuer la même suite d’opérations à plusieurs endroits de votre 

syntaxe php

Vu sur pierre-giraud.fr

syntaxe php

Vu sur w3resource.com

pour être totalement complet sur le sujet, il est (en théorie) également possible d’utiliser <? à la place de <?php ou encore mais ces syntaxes sont fortement déconseillées. contrairement aux syntaxes précédentes elles ne permettent pas par exemple d’avoir un script php valide d’un point de vue xml (ce qui 
basic php syntax.

Voir la suite

Blogs

Infos

Ajouter une source ?

Envoyez un email avec l'URL du site et du flux à planetephpfr AT afup POINT org

Gestion

AFUP