PHP - Php7 - Confirmed
Hello
I've heard new PHP version (7) is on its way. Since I didn't found any thread laying around already. I guess, lets discuss it.
Estimated remaining time until early alpha is around a year. And stable release is expected to be in 2016/2017.
Edited by OmegaExtern, 07 August 2014 - 05:02 PM. Similar TutorialsThis topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=333559.0 I have an interface with method: public function foo(string $arg1, string $arg2); With PHP7.4, I can have a class relax the type without errors such as Dog::foo(string $arg1, $arg2) ($arg2 is not required to be a string) I incorrectly thought I could even relax the constraint more such as Dog::foo(string $arg1){} and not even pass $arg2 because extra arguments which exceed a method's placeholders are ignored without error but I received error: Declaration of Dog::foo(string $arg1) must be compatible with AnimalInterface::foo(string $arg1, string $arg2). Are my only options to include $arg2=null in the relaxed methods and label the methods something $dummy1, $dummy2..., or pass them in an array (which I don't wish to do)? Is passing extra parameters to the same method as I am doing considered bad practice, and if so what is considered the correct way? Thanks
<?php declare(strict_types=1); ini_set('display_errors', '1'); echo "PHP Version: ".PHP_VERSION.PHP_EOL; // => PHP Version: 7.4.1 interface AnimalInterface { public function foo(string $arg1, string $arg2); } abstract class Animal implements AnimalInterface { protected string $name; public function __construct(string $name) { $this->name = $name; } protected function test($method, $arg1, $arg2) { echo $method.' '.$this->name.' '.gettype($arg1).' '.gettype($arg2).PHP_EOL; } } class Cat extends Animal { public function foo(string $arg1, string $arg2) { $this->test(__FUNCTION__, $arg1, $arg2); } public function bar(string $arg1, string $arg2) { $this->test(__FUNCTION__, $arg1, $arg2); } } class Dog extends Animal { //public function foo(string $arg1){} //generates an error public function foo(string $arg1, $arg2=null) { $this->test(__FUNCTION__, $arg1, $arg2); } public function bar(string $arg1) { $arg2=$arg2??null; $this->test(__FUNCTION__, $arg1, $arg2); } } $kitty = new Cat("Ricky"); $doggy = new Dog("Mavrick"); $kitty->foo('arg1', 'arg2'); $doggy->foo('arg1', [1,2,3]); //$kitty->bar('arg1', (int)222); //will error using strict mode only $doggy->bar('arg1', (int)222); $kitty->bar('arg1', 'arg2'); $doggy->bar('arg1', [1,2,3]);Quote
PHP Version: 7.4.1
Fatal error: Uncaught Error: Call to undefined method FPDF::TextWithRotation() in C:\laragon\www\arx\fpdf\rot.php:8 Stack trace: #0 {main} thrown in C:\laragon\www\arx\fpdf\rot.php on line 8 this issue is coming in my file don't knw i want to rotate my text in pdf
<?php require('rpdf.php');
$pdf=new FPDF();
$pdf->AddPage(); $pdf->SetFont('Arial','',40); $pdf->TextWithRotation(50,65,'Hello',45,-45); $pdf->SetFontSize(30); $pdf->TextWithDirection(110,50,'world!','L'); $pdf->TextWithDirection(110,50,'world!','U'); $pdf->TextWithDirection(110,50,'world!','R'); $pdf->TextWithDirection(110,50,'world!','D'); $pdf->Output(); ?>
please help me Edited August 11, 2020 by Ali9980Hi, In < PHP7.3, is it possible to set the session.cookie_samesite to "none' and secure to do away with the warning messages of chrome ? Thanks.
Please can some one help me. We have upgraded php and not i cant get the php page to correctly redirect the user to the login page if the user has not logged in and the get it to redirect to the index page. So the form sequence is as follows. User connects to index page, user clicks on link to add or delete data in mysql database, page must redirect to login page if user has not logged in, once logged in login page must redirect to add or delete page depending on the link clicked on. Addins and deleting data to the mysql database table works fine.
Below is the add,php page.
<?php
ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
session_start(); //start session. if(!isset($_GET['name'])){//added this to check if name is sent include('database.php'); if (!isset($_SESSION["user.id"]) && $_SESSION["user.id"] !="") { } else{ header("Location: login.php"); }
if($_POST['action']) {
include('email.php'); $address=""; $name=$_POST['name']; $extension=$_POST['extension']; $department=$_POST['department']; $phone=$_POST['phone']; $email=$_POST['email'];
$sql = "INSERT INTO users (ID, Name, Email, Extension, Phone, Department) VALUES (NULL, '$name', '$email', '$extension', '$phone', '$department')";
if ($conn->query($sql) === TRUE) echo "New record added"; else echo "Error: " . $sql . "<br>" . $conn->error; $conn->close(); }
?>
<style type="text/css"> <!-- form { font-family: "Courier New", Courier, mono} body { font-family: "Times New Roman", Times, serif} --> </style>
<center><form action="" method="POST"> Name:<br><input type="text" name="name" required pattern=".*[ ].*" title="Please enter Name and Surname." ><br /> Email:<br><input type="text" name="email" required placeholder="@alpinemotors.co.za" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$" title="Must be a valid email address, eg: user@mail.co.za" ><br /> Extension:<br><input type="text" name="extension" required pattern="^\d{4}( \/ \d{4})?$" title="Please Enter the Extension Number"><br /> Phone:<br><input type="text" name="phone" pattern="^\d{3} \d{3} \d{4}$" title="Please enter a valid Cellphone Number, eg. 083 511 9213"><br /> Department:<br> <select name ="department"> <option value="ADMIN">ADMIN</option> <option value="FINANCIAL MANAGER">FINANCIAL MANAGER</option> <option value="AFTER-SALES DIRECTOR">AFTER-SALES DIRECTOR</option> <option value="ALPINE SALES DIRECTOR">ALPINE SALES DIRECTOR</option> <option value="DEALER PRINCIPAL">DEALER PRINCIPAL</option> <option value="AUTO ARMOUR/AUTO ENHANCE - FITMENT CENTRE (Smash and Grab)">AUTO ARMOUR/AUTO ENHANCE - FITMENT CENTRE (Smash and Grab)</option> <option value="BANDIT">BANDIT</option> <option value="BIDTRACK">BIDTRACK</option> <option value="WORKSHOP BOOKINGS">WORKSHOP BOOKINGS</option> <option value="CLEANERS">CLEANERS</option> <option value="COMMERCIAL SALES DIRECTOR">COMMERCIAL SALES DIRECTOR</option> <option value="WORKSHOP WASHBAY">WORKSHOP WASHBAY</option> <option value="FINANCE AND INSURANCE OFFICE">FINANCE AND INSURANCE OFFICE</option> <option value="FINANCE AND INSURANCE MANAGER">FINANCE AND INSURANCE MANAGER</option> <option value="IT DEPARTMENT">IT DEPARTMENT</option> <option value="MARKETING DIRECTOR">MARKETING DIRECTOR</option> <option value="MARKETING DEPARTMENT">MARKETING DEPARTMENT</option> <option value="MASTER CARS SALES">MASTER CARS SALES</option> <option value="MASTER CARS SALES MANAGER">MASTER CARS SALES MANAGER</option> <option value="PREP DEPARTMENT">PREP DEPARMENT</option> <option value="NUMBER PLATES">NUMBER PLATES</option> <option value="PANELBEATER - EASIFIX - CAR CARE">PANELBEATER - EASIFIX - CAR CARE</option> <option value="PARTS MANAGER">PARTS MANAGER</option> <option value="PARTS">PARTS</option> <option value="PARTS DISPATCH">PARTS DISPATCH</option> <option value="PARTS TELESALES">PARTS TELESALES</option> <option value="TRADE SALES MANAGER">TRADE SALES MANAGER</option> <option value="WASHBAY">WASHBAY</option> <option value="MASTER CARS PREP AND ORDERS">MASTER CARS PREP AND ORDERS</option> <option value="NEW CARS ADMIN AND STOCK CONTROL">NEW CARS ADMIN AND STOCK CONTROL</option> <option value="NEW CARS SHOWROOM">NEW CARS SHOWROOM</option> <option value="NEW CARS SALES MANAGER">NEW CARS SALES MANAGER</option> <option value="WORKSHOP SERVICE ADVISORS">WORKSHOP SERVICE ADVISORS</option> <option value="WORKSHOP">WORKSHOP</option> <option value="WORKSHOP FOREMEN">WORKSHOP FOREMEN</option> <option value="WAREHOUSE">WAREHOUSE</option> <option value="WARRANTY & CLAIMS">WARRANTY & CLAIMS</option> <option value="WORKSHOP DRIVERS">WORKSHOP DRIVERS</option> <option value="WORKSHOP MANAGER">WORKSHOP MANAGER</option> </select> <br /> <br><input type="submit" name="action" value="Submit"> <input type="reset" value="Reset"> </form> <a href="index.php">Extension List</a> </center> </html> }
Below is the login.php
<?php
ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
session_start(); // Starting Session $error = ''; // Variable To Store Error Message if (isset($_POST['submit'])) { if (empty($_POST['username']) || empty($_POST['password'])) { $error = "Username or Password is invalid"; } else{ // Define $username and $password $username = $_POST['username']; $password = $_POST['password']; // mysqli_connect() function opens a new connection to the MySQL server. $conn = mysqli_connect("localhost", "root", "Pr1v@cY", "T-List_VW"); // SQL query to fetch information of registerd users and finds user match. $query = "SELECT * from UserName where userName=? AND pass=? LIMIT 1"; // To protect MySQL injection for Security purpose $stmt = $conn->prepare($query); $stmt->bind_param("ss", $username, $password); $stmt->execute(); $stmt->bind_result($username, $password); $stmt->store_result(); if($stmt->fetch()) //fetching the contents of the row { $_SESSION['login_user'] = $username; // Initializing Session header("location: index.php"); // Redirecting To Profile Page } mysqli_close($conn); // Closing Connection } ?>
<!DOCTYPE html> <html> <head> <title>Login Form in PHP with Session</title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <div id="login"> <h2>Login Form</h2> <form action="" method="post"> <label>UserName :</label> <input id="name" name="username" placeholder="username" type="text"> <label>Password :</label> <input id="password" name="password" placeholder="**********" type="password"><br><br> <input name="submit" type="submit" value=" Login "> <span><?php echo $error; ?></span> </form> </div> </body> </html>
I have used this program for many years without problems. I have not altered the file in any way, so why is this happening? Is it to do with PHP upgrade?😖 Here is the file: <?php include("connect_Verses4Cards.php"); $conn=get_db_conn_verse(); session_start(); $display_block =""; $color=""; $r =""; $g =""; $b =""; $image =""; //Get the Card Variables $Get_Size_sql = "SELECT * FROM `CSize` WHERE `Size` ='".$_POST["CSize"]."'"; $Get_Size_res = mysqli_query($conn, $Get_Size_sql) or die(mysqli_error($conn)); if (mysqli_num_rows($Get_Size_res) < 1) { //this Card does not exist $display_block = "You have selected an invalid Card size. Please try again."; } else { //get the print variables while ($Size_info = mysqli_fetch_array($Get_Size_res)) { $BoxX = stripslashes($Size_info['BoxX']); $Cellw = stripslashes($Size_info['Cellw']); $Cellh = stripslashes($Size_info['Cellh']); $SizeI = stripslashes($Size_info['Size']); $SID = stripslashes($Size_info['SID']); $floatx = stripslashes($Size_info['floatx']); $floaty = stripslashes($Size_info['floaty']); $floatw = stripslashes($Size_info['floatw']); $floath = stripslashes($Size_info['floath']); $ort = stripslashes($Size_info['ort']); } //create the display string $display_block = "$ort"; } //verify the Event exists //$the_id = mysqli_real_escape_string($mysqli, $_SESSION[VID]); $Get_Verse_sql = "SELECT id, Event, Sub_Type, Verse FROM verses WHERE id='".$_SESSION['Test']."'"; $Get_Verse_res = mysqli_query($conn, $Get_Verse_sql) or die(mysqli_error($conn)); if (mysqli_num_rows($Get_Verse_res) < 1) { //this Event does not exist $display_block = "You have selected an invalid Event. Please try again."; } else { //get the Event ID while ($Verse_info = mysqli_fetch_array($Get_Verse_res)) { $Verse = stripslashes($Verse_info['Verse']); } //create the display string $display_block = "$Verse"; //free results mysqli_free_result($Get_Verse_res); mysqli_free_result($Get_Size_res); //close connection to MySQL } mysqli_close($conn); require('fpdf.php'); class PDF extends FPDF { var $B; var $I; var $U; var $HREF; function PDF($orientation='P', $unit='mm', $size='A4') { // Call parent constructor $this->FPDF($orientation,$unit,$size); // Initialization $this->B = 0; $this->I = 0; $this->U = 0; $this->HREF = ''; } function SetStyle($tag, $enable) { // Modify style and select corresponding font $this->$tag += ($enable ? 1 : -1); $style = ''; foreach(array('B', 'I', 'U') as $s) { if($this->$s>0) $style .= $s; } $this->SetFont('',$style); } } $color = $_POST['color']; $r = substr($color,0,3); $g = substr($color,3,3); $b = substr($color,6,3); $image=$_POST['image']; $pdf = new PDF($ort,'mm','A4'); $pdf->AddPage(); $pdf->AddFont('French Script MT','','/frscript.php'); $pdf->AddFont('Batavia','','Batavia_.php'); $pdf->AddFont('Algerian','','Alger.php'); $pdf->AddFont('Bladerunner','','BLADRMF_.php'); $pdf->AddFont('Brush Script','','BRUSHSCI.php'); $pdf->AddFont('Helterskelter','','Helte___.php'); $pdf->AddFont('Justice','','Justice_.php'); $pdf->AddFont('Magneto','','MAGNETOB.php'); $pdf->AddFont('Old English','','OldEngl.php'); $pdf->AddFont('Sneakerhead Outline','','Sneabo__.php'); $pdf->AddFont('Trendy','','Trendy__.php'); $pdf->AddFont('Vladimir Script','','VLADIMIR.php'); $pdf->SetLeftMargin('float0'); $pdf->SetTextColor($r,$g,$b); $pdf->SetFont($_POST['fontface'],'',$_POST['font']); $pdf->SetXY($BoxX, $_POST['Top']); $pdf->Image($image,$floatx,$floaty,$floatw,$floath,'',''); $pdf->MultiCell($Cellw,$Cellh,$display_block,'' ,'C'); //$pdf->SetDisplayMode('fullpage',''); $pdf->SetFont(''); $pdf->Output('verse.pdf','D'); //end: ?>
I have been at this for several hours..
<?php ?> I keep getting: Parse error: syntax error, unexpected '?>', expecting ',' or ')' in C:\Apache24\htdocs\mysql_connect.php on line 4 I have tried copy and paste of mysqli_connect from several different web pages, nothing works. PHP is installed correctly, I have a db in MySQL, and Apache is installed with no errors. what the... Edited March 31, 2019 by eljaydeetypo I have a huge application(multi-year) where I do the normal $varX= $var1 + $var2. I get Warning: A non-numeric value encountered because var1 or var 2 are string. I know the right thing will be to intval(), but I just cant go over so much of the application. I read to just disable warning, but I think thats worst because I will not be able to see new warnings. Is there any php.ini solution were php can work as before on math operations? I guess I can ini_set on all the old files and dont do it on the new ones). If there is another accepted solution, please let me know Thank you
|